Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PrincipalContext principalContext =
- new PrincipalContext(ContextType.Domain,
- domainName.Trim(),
- domainContainer.Trim());
- PrincipalContext principalContext = new PrincipalContext(ContextType.Domain);
- // define a "query-by-example" principal - here, we search for all users
- UserPrincipal qbeUser = new UserPrincipal(principalContext);
- // create your principal searcher passing in the QBE principal
- PrincipalSearcher srch = new PrincipalSearcher(qbeUser);
- // find all matches
- foreach (var found in srch.FindAll())
- {
- UserPrincipal user = found as UserPrincipal;
- if (user != null)
- {
- Console.WriteLine(user.SamAccountName);
- }
- }
- var context = new PrincipalContext(ContextType.Domain);
- var context = new PrincipalContext(ContextType.Domain, domainName, domainContainer);
- new DirectoryEntry("LDAP://domain_name/container")
- new DirectoryEntry("LDAP://domain_name/rootDse")
Add Comment
Please, Sign In to add comment