Simon

Simon

  • NA
  • 9
  • 0

ASP.NET (C#) & Active Directory

Oct 9 2006 4:31 AM
I use the Example of this Page (http://www.c-sharpcorner.com/Code/2005/June/ADand.NET.asp). But the Point 3 doen't work.

3. Validate if a user exists
///


/// Method to validate if a user exists in the AD.
///

///
///
public bool UserExists(string UserName){
DirectoryEntry de = ADHelper.GetDirectoryEntry();
DirectorySearcher deSearch = new DirectorySearcher();
deSearch.SearchRoot =de;
deSearch.Filter = "(&(objectClass=user) (cn=" + UserName +"))";
SearchResultCollection results = deSearch.FindAll();
if(results.Count == 0){
return false;
}
else{
return true;
}
}

In the Code is a Class ADHelper, but this Class dosen't exist. Is this Example not finished or what is the problem?
I really need this Script. I have a Project in my company. To say is, that i'm a Noobie. My question is maybe stupid, but i hope you can help me?

Thank you very much!!
Greetz Simon


Answers (7)