Connecting to Active Directory
Windows Forms
1
Posts
1
Posters
0
Views
1
Watching
-
I have a login form which will connect the Active Directory to check the user; but the output that i get is alway not couldn't connect. Boolean Success = false; DirectoryEntry Entry = new DirectoryEntry("LDAP://" + Domain, UserName, Password); DirectorySearcher Searcher = new DirectorySearcher(Entry); Searcher.SearchRoot = Entry; Searcher.Filter = "(&(objectClass=user)(sAMAccountName=" + UserName + "))"; Searcher.PropertiesToLoad.Add("cn"); Searcher.SearchScope = SearchScope.Subtree; try { //Test = UserExists(Domain, UserName, Password); SearchResult Results = Searcher.FindOne(); Success = (Results != null); } please help me to find the solution.
Regards, John.L.Ponratnam