public void check() { // Connect to LDAP AuthenticationTypes authTypes; // Authentication flags. authTypes = AuthenticationTypes.Signing | AuthenticationTypes.Sealing | AuthenticationTypes.Secure; string domainAndUsername = "xglobal" + @"\" + TextBox1.Text; DirectoryEntry oAuthedEntry = new DirectoryEntry(); // Create new DirectorySearcher instance DirectorySearcher search = new DirectorySearcher(oAuthedEntry); // Set search criteria search.Filter = "(objectCategory=user)"; //search.PropertiesToLoad.Add("displayName"); // name //search.PropertiesToLoad.Add("physicalDeliveryOfficeName"); // location search.PropertiesToLoad.Add("telephoneNumber"); // phone number search.PropertiesToLoad.Add("mobile"); // mobile //search.PropertiesToLoad.Add("mail"); // email address //search.PropertiesToLoad.Add("msDS-UserAccountDisabled"); // account status //search.PropertiesToLoad.Add("title"); // title //search.PropertiesToLoad.Add("ms-DS-UserAccountAutoLocked"); // locked search.Filter = String.Format("(SAMAccountName={0})", TextBox1.Text); // Perform the search SearchResultCollection results = null; try { results = search.FindAll(); Response.Write(results .ToString());
} catch (Exception searchEx) { throw new Exception("Error obtaining users results. ", searchEx); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)