// Verify the required method.
Public static bool isauthenticated (string domain, string username, string PWD)
{
String strpath = "LDAP: // ou = people, Dc = rcomm, Dc = Local ";
String domainandusername = domain + @ "\" + username;
Directoryentry entry = new directoryentry (strpath, domainandusername, PWD );
Try
{// Bind to the native adsobject to force authentication.
Object OBJ = entry. nativeobject;
Directorysearcher search = new directorysearcher (entry );
Search. Filter = "(samaccountname =" + username + ")";
Search. propertiestoload. Add ("cn ");
Searchresult result = search. findone ();
If (null = Result)
{
Return false;
}
// Update the new path to the user in the directory.
Strpath = result. path;
// _ Filterattribute = (string) result. properties ["cn"] [0];
}
Catch (exception ex)
{
// Throw new exception ("error Authenticating user." + ex. Message );
Return false;
}
Return true;
}
// Call
If (loginlayer. isauthenticated ("Kefeng. rcomm. Local", "someguy", "admin "))
{
Response. Write ("Verification Successful! ");
}
Else
{
Response. Write ("Verification Failed! ");
}