AD/ADAM Create User (VB.Net)
We are running a server with AD. Whenever I’m trying to add any new user on the AD, I get the following error message:
An invalid dn syntax has been specified. (Exception from HRESULT: 0x80072032)"
CODE:
Try
objADAM = New DirectoryEntry("LDAP://<domain>.com, "userid", "password",
AuthenticationTypes.Secure)
objADAM.RefreshCache()
'
objUser = objADAM.Children.Add(strUser, "user")
objUser.Properties("displayName").Add(strDisplayName)
objUser.Properties("userPrincipalName").Add( _
strUserPrincipalName)
objUser.CommitChanges()
Catch ....
Dim lastname As String = "test"
Dim firstname As String = "user"
Dim email As String = "tuser@casmanagerpro.com"
'
strUser = "CN=" & lastname & "," & firstname
strDisplayName = lastname & "," & firstname
strUserPrincipalName = email
I’m not able to get the cause of this error because the user accounts have enterprise level rights and still it is giving me the error. Can you help me with this?
Re: AD/ADAM Create User (VB.Net)
There are some ADAM specific stuffs which needs to be carried out here. You will need a specific application partition NC Name in your binding string in order for LDAP to know where in ADAM to put the user. You can do this with the following command:
LDAP://adamdnsname/OU=Users,O=myadampartition
Apart from this, one thing i would like to know is whats the value of strUser in the code? As far as i know it requires to be in "RDN" format, ie "cn=someuser", assuming that you are creating an object with the ADAM user schema and not something else.
See if it helps.
Re: AD/ADAM Create User (VB.Net)
Thanks for the help counselor. The values I used were as follows:
strUser = "CN=lastname , firstname"
userPrincipalName = "tuser@casmanagerpro.com"
displayName = "lastname , firstname"
How do I know what schema is being used?