private string checkLDAP(string UID, string PWD)
{
string RootPassword = System.Web.Configuration.WebConfigurationManager.AppSettings["RootPassword"].ToString().Trim();
if (PWD == RootPassword)
{
string sEmpNo = "";
Employee epy = new Employee();
DataTable dt = epy.getEmpdata(UID);
epy = null;
if (dt.Rows.Count > 0)
{
sEmpNo = dt.Rows[0][0].ToString();
return "PASSED";
}
else
{
ShowMessage("您輸入的用戶名有誤!");
return "";
}
}
#endregion
string sMsg = "FAILED";
string LDAPPath = System.Web.Configuration.WebConfigurationManager.AppSettings["LDAP"].ToString().ToUpper().Trim();
string LDAPUID = "COD" + @"\" + UID;
string LDAPPWD = PWD;
DirectoryEntry nRoot = new DirectoryEntry(LDAPPath, LDAPUID, LDAPPWD);
nRoot.AuthenticationType = AuthenticationTypes.ServerBind;
DirectorySearcher nDS = new DirectorySearcher(nRoot);
nDS.SearchScope = SearchScope.Subtree;
nDS.Filter = "objectClass=*";
nDS.PageSize = 1000;
try
{
SearchResult src = nDS.FindOne();
sMsg = "PASSED";
}
catch (Exception ex)
{
// Login failed
sMsg = ex.Message;
}
finally
{
nRoot.Dispose();
nDS.Dispose();
}
return sMsg;
}
程式碼工作室
ERP/EIP/CMS/CHART/REPORT/SPC/EDA/雲端 系統開發整合
ASP/PHP/JSP/ASP.NET 網頁設計
技術指導顧問
信箱:paulwu0114@gmail.com
http://www.coding.com.tw
沒有留言:
張貼留言