Public bool ispass (string useraccount, string password)
{
String domainname = "DC = syqueyry, Dc = com, Dc = cn ";
String adpath = "LDAP: // syqueyry. com. cn ";
String addomain = "syqueyry ";
// Obtain the path in the current domain
String _ adpath = adpath + "/" + addomain;
String domainandusername;
Bool hasdomain = false;
If (useraccount. startswith (domainname, stringcomparison. currentcultureignorecase ))
{
Hasdomain = true;
}
If (hasdomain)
{
Domainandusername = useraccount;
}
Else
{
Domainandusername = domainname + @ "\" + useraccount;
}
Directoryentry entry = new directoryentry (_ adpath, domainandusername, password );
Directorysearcher search = new directorysearcher (entry );
If (hasdomain)
{
Useraccount = useraccount. substring (domainname. Length + 1 );
}
Search. Filter = "(samaccountname =" + useraccount + ")";
Search. propertiestoload. Add ("displayname ");
Searchresult aduser = NULL;
Try
{
Aduser = search. findone ();
If (aduser = NULL)
{
_ Error = "domain authentication failed ";
}
Else
{
If (convert. toint32 (aduser. properties ["useraccountcontrol"] [0]) = 2)
{
_ Myuser = new myuser (useraccount, password, aduser. properties ["displayname"]. tostring ());
}
Else
{
_ Error = "this user has been disabled ";
}
Aduser = NULL;
}
}
Catch (exception ex)
{
_ Error = ex. message;
Aduser = NULL;
}
Finally
{
Entry. Close ();
Entry = NULL;
Search. Dispose ();
Search = NULL;
}
Return aduser! = NULL;
}
Welcome to: http: // 121.18.78.216, which is a demonstration platform for ease of query and analysis, workflow, content management, and project management.