Guest User

Untitled

a guest
Jan 10th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. PrincipalContext principalContext =
  2. new PrincipalContext(ContextType.Domain,
  3. domainName.Trim(),
  4. domainContainer.Trim());
  5.  
  6. PrincipalContext principalContext = new PrincipalContext(ContextType.Domain);
  7.  
  8. // define a "query-by-example" principal - here, we search for all users
  9. UserPrincipal qbeUser = new UserPrincipal(principalContext);
  10.  
  11. // create your principal searcher passing in the QBE principal
  12. PrincipalSearcher srch = new PrincipalSearcher(qbeUser);
  13.  
  14. // find all matches
  15. foreach (var found in srch.FindAll())
  16. {
  17. UserPrincipal user = found as UserPrincipal;
  18. if (user != null)
  19. {
  20. Console.WriteLine(user.SamAccountName);
  21. }
  22. }
  23.  
  24. var context = new PrincipalContext(ContextType.Domain);
  25.  
  26. var context = new PrincipalContext(ContextType.Domain, domainName, domainContainer);
  27.  
  28. new DirectoryEntry("LDAP://domain_name/container")
  29.  
  30. new DirectoryEntry("LDAP://domain_name/rootDse")
Add Comment
Please, Sign In to add comment