Guest User

Untitled

a guest
Jan 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. public static PrincipalContext GetPrincipalContext()
  2. {
  3. return new PrincipalContext(ContextType.Domain);
  4. }
  5.  
  6. public static UserPrincipal GetUser(string sUserName)
  7. {
  8. //Save documents to library
  9. PrincipalContext oPrincipalContext = GetPrincipalContext();
  10. UserPrincipal oUserPrincipal =
  11. UserPrincipal.FindByIdentity(oPrincipalContext, sUserName);
  12. return oUserPrincipal;
  13. }
  14.  
  15. at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
  16. at System.DirectoryServices.DirectoryEntry.Bind()
  17. at System.DirectoryServices.DirectoryEntry.get_AdsObject()
  18. at System.DirectoryServices.PropertyValueCollection.PopulateList()
  19. at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)
  20. at System.DirectoryServices.PropertyCollection.get_Item(String propertyName)
  21. at System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInitNoContainer()
  22. at System.DirectoryServices.AccountManagement.PrincipalContext.DoDomainInit()
  23. at System.DirectoryServices.AccountManagement.PrincipalContext.Initialize()
  24. at System.DirectoryServices.AccountManagement.PrincipalContext.get_QueryCtx()
  25. at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(PrincipalContext context, Type principalType, Nullable`1 identityType, String identityValue, DateTime refDate)
  26. at System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(PrincipalContext context, String identityValue)
Add Comment
Please, Sign In to add comment