Created
November 22, 2017 18:06
-
-
Save ScriptingPro/1dfc1cb33bbd3b95f9f7f44ac5629e29 to your computer and use it in GitHub Desktop.
LdapConnection AddRequest SendRequest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$AuthenticationType = [System.DirectoryServices.AuthenticationTypes]::Secure | |
$DirectoryConnection = New-Object -TypeName System.DirectoryServices.Protocols.LdapConnection -ArgumentList "ldapserver.domain.com:777,uid=newuser,ou=people,dc=company,dc=com", $password , $AuthenticationType | |
$DirectoryConnection.Bind() | |
$DirectoryRequest = New-Object -TypeName System.DirectoryServices.Protocols.AddRequest | |
$DirectoryRequest.DistinguishedName = "uid= xxxx, ou=user, o=company" | |
$DirectoryRequest.Attributes.Add((New-Object -TypeName System.DirectoryServices.Protocols.DirectoryAttribute -ArgumentList "objectclass",@("top","organizationalPerson","person","inetorgperson","inetuser","mailrecipient","pwmuser","posixAccount"))) | Out-Null | |
$DirectoryRequest.Attributes.Add((New-Object -TypeName System.DirectoryServices.Protocols.DirectoryAttribute -ArgumentList "cn",($FirstName+" "+$LastName))) | Out-Null | |
$DirectoryConnection.SendRequest($DirectoryRequest) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @ScriptingPro ,
How can I add a attribute "Description" that has Key value pairs?
For ex:
$DirectoryRequest.Attributes.Add((New-Object -TypeName System.DirectoryServices.Protocols.DirectoryAttribute -ArgumentList "Description",@("AppName"="sampleapp","AppId"="1234")
It would be great if I get your help on this..Thanks in advance!!