Guest User

Untitled

a guest
Aug 16th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. DirectoryEntry directoryEntry = new DirectoryEntry(ldaPath, domainName+"\"+ userName, Password);
  2.  
  3. if (directoryEntry != null)
  4. {
  5. DirectorySearcher searchEntry = new DirectorySearcher(directoryEntry);
  6. searchEntry.Filter = "(SAMAccountname=" + userName + ")";
  7. SearchResult result = searchEntry.FindOne();
  8. if (result != null)
  9. {
  10. DirectoryEntry userEntry = result.GetDirectoryEntry();
  11. if (userEntry != null)
  12. {
  13. userEntry.Invoke("SetPassword", new object[] { newPassword });
  14. userEntry.Properties["lockouttime"].Value = 0;
  15. }
  16. }
  17. }
Add Comment
Please, Sign In to add comment