Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. $server = "master.ldap.ucalgary.ca"
  2. $path = "ou=uidauthent,o=ucalgary.ca"
  3. #$path= "ou=people,o=ucalgary.ca"
  4. $DN = "LDAP://$server/$path"
  5. $filter = "(uid=*)"
  6. $user = "rsousa"
  7. $password = "password"
  8.  
  9.  
  10.  
  11. $auth = [System.DirectoryServices.AuthenticationTypes]::FastBind
  12. #$Domain = New-Object System.DirectoryServices.DirectoryEntry($DN,$user,(GetSecurePass $Password),$auth)
  13. #$Domain = New-Object System.DirectoryServices.DirectoryEntry($DN,$user,$password,$auth)
  14. $Domain = New-Object System.DirectoryServices.DirectoryEntry($DN,$null,$null,$auth)
  15. $Searcher = New-Object System.DirectoryServices.DirectorySearcher
  16.  
  17. $Searcher.SearchRoot = $Domain
  18. $Searcher.Filter = $Filter
  19.  
  20.  
  21. #$Searcher.PropertiesToLoad.Add("owner") >$null ;
  22. #$Searcher.PropertiesToLoad.Add("ucid") >$null;
  23. #$Searcher.PropertiesToLoad.Add("uid") >$null;
  24. #$Searcher.PropertiesToLoad.Add("description") >$null;
  25.  
  26. [byte[]]$values = @();
  27.  
  28. $Searcher.FindAll()
  29. foreach($prop in $Searcher.FindAll().Properties){
  30. foreach($name in $prop.PropertyNames){
  31. [byte[]]$values = @();
  32. #$("Name = $name");
  33. foreach($value in $prop[$name]){
  34. if($value -is [byte[]]){
  35. foreach($byteval in $value){
  36. $values += $byteval;
  37. }
  38. }
  39. elseif($value -is [String]){
  40. $($name + ": " + $value);
  41.  
  42. }
  43. }
  44. if($values.Count -gt 0){
  45. $Encode = new-object system.text.asciiencoding;
  46. $($name +": " + $Encode.GetString($values));
  47. }
  48. }
  49. }
  50.  
  51.  
  52. ($Searcher.FindAll()).Count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement