Searching Novell NDS eDirectory with Powershell
Today we had to search a NDS eDirectory via Powershell script. After some tests and searching the internet we found the following solution.
Note:
When accessing the returned figures in the attributes it is important for the attribute-names to be spelled in lower case! ( $entry[0].attributes[“mail“] )
Index
Powershell script to search Novell NDS eDirectory
set-variable “ADS_SCOPE_SUBTREE” 2 -op Constant
[reflection.assembly]::LoadWithPartialName(“system.directoryservices.protocols”) | out-null$ldapIdentifier = new-object directoryservices.protocols.ldapdirectoryidentifier(“firstattribute.com”)
$ldapConnection = new-object directoryservices.protocols.ldapconnection($ldapIdentifier,$null,0) [string[]]$attr = “cn”,”mail”
$dn = “o=FIRSTATTRIBUTE”
$filter = “(uid=waniert)”
$scope = $ADS_SCOPE_SUBTREE
$searchRequest = new-object directoryservices.protocols.searchrequest($dn,$filter,$ADS_SCOPE_SUBTREE,$attr)
$searchRequest.typesonly = $false
$searchRequest.sizelimit = 10
$result = [directoryservices.protocols.searchresponse]$ldapConnection.sendrequest($searchRequest)
$entry = $result.entries
$Name = ($entry[0].attributes[“cn”])[0] $Mail = ($entry[0].attributes[“mail”])[0]
Write-Host “Name : ” + $Name
Write-Host “Mail : ” + $Mail
Searching Active Directory with Powershell
Besides searching eDirectory with PowerShell, there is also a nice article to search Active Directry using Powershell commands:
http://technet.microsoft.com/en-us/library/ff730967.aspx
Leave a Reply
<p>Your email is safe with us.<br/>Information about our <a href="https://activedirectoryfaq.com/contact-us/">data protection policies</a></p>