Hello Scripting Guy,
I have been tasked with taking a .Net program/project and converting it to PowerShell. The .Net program exported three sources of information and inserts those exports into a SQL database for multiple functions and reasons. The three sources are AD, eDirectory, and PeopleSoft. The AD was simple with the "Module for Active Directory" and "SQLPS". Now, I need to connect to eDirectory via LDAP and query the source. I am able to connect/bind to the eDirectory and search but I need to enumerate the directory and insert that into a SQL table. Given the logic I have developed for AD, it will be no problem inserting the records into SQL but I have not found anything to get my over the hurdle of enumerating the directory. Below is the code that I found to successfully connect with eDirectory and perform a search. Thank you.
Connection Setup $eDir = New-Object System.DirectoryServices.Protocols.LdapDirectoryIdentifier('1.2.3.4','389') $eDirCreds = New-Object System.Net.NetworkCredential('cn=ConnectID,o=Home','MyConnectPS') $ED = New-Object System.DirectoryServices.Protocols.LdapConnection($eDir,$eDirCreds) $ED.SessionOptions.SecureSocketLayer = $False $ED.AuthType = 'Basic' $ED.Bind();
Search eDirectory records $SearchScope = [System.DirectoryServices.Protocols.SearchScope]::SubTree $SearchAttributeList = ,"*" <--- Not quit sure why the "," proceeds the "*" $SearchBaseDN = "o=Home" $SearchFilter = "(uid=SomeUser)" $SearchReq = new-object System.DirectoryServices.Protocols.SearchRequest -ArgumentList $SearchBaseDN,$SearchFilter,$SearchScope,$SearchAttributeList $SR = $ED.SendRequest($SearchReq)
$SR displays ResultCode of success found or not found but if found contains DN in the "Entries" field.
MatchedDN :
Controls : {}
ResultCode : Success
ErrorMessage :
Referral : {}
References : {}
Entries : {cn=MyID,ou=OU1,ou=OU2,o=Home}
RequestId :