Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $server = "master.ldap.ucalgary.ca"
- $path = "ou=uidauthent,o=ucalgary.ca"
- #$path= "ou=people,o=ucalgary.ca"
- $DN = "LDAP://$server/$path"
- $filter = "(uid=*)"
- $user = "rsousa"
- $password = "password"
- $auth = [System.DirectoryServices.AuthenticationTypes]::FastBind
- #$Domain = New-Object System.DirectoryServices.DirectoryEntry($DN,$user,(GetSecurePass $Password),$auth)
- #$Domain = New-Object System.DirectoryServices.DirectoryEntry($DN,$user,$password,$auth)
- $Domain = New-Object System.DirectoryServices.DirectoryEntry($DN,$null,$null,$auth)
- $Searcher = New-Object System.DirectoryServices.DirectorySearcher
- $Searcher.SearchRoot = $Domain
- $Searcher.Filter = $Filter
- #$Searcher.PropertiesToLoad.Add("owner") >$null ;
- #$Searcher.PropertiesToLoad.Add("ucid") >$null;
- #$Searcher.PropertiesToLoad.Add("uid") >$null;
- #$Searcher.PropertiesToLoad.Add("description") >$null;
- [byte[]]$values = @();
- $Searcher.FindAll()
- foreach($prop in $Searcher.FindAll().Properties){
- foreach($name in $prop.PropertyNames){
- [byte[]]$values = @();
- #$("Name = $name");
- foreach($value in $prop[$name]){
- if($value -is [byte[]]){
- foreach($byteval in $value){
- $values += $byteval;
- }
- }
- elseif($value -is [String]){
- $($name + ": " + $value);
- }
- }
- if($values.Count -gt 0){
- $Encode = new-object system.text.asciiencoding;
- $($name +": " + $Encode.GetString($values));
- }
- }
- }
- ($Searcher.FindAll()).Count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement