ADAM ADSI Create fails with 80072032, "invalid DN syntax"

  • Thread starter Thread starter Mike C
  • Start date Start date
M

Mike C

Hi,

I am trying to create a user object in an ADAM directory using ADSI.
It fails at the .SetInfo call, with error code 80072032, "An invalid dn
syntax has been specified".
I can't for the life of me see what can be wrong with the DN syntax.

The ADAM directory is running on Windows 2003 Server, Enterprise Edition
configured as a Primary Domain Controller, with Active Directory. The code
below fails when binding as a Windows principal or ADAM principal.
I did wonder if permissions or user rights may be an issue, but the Windows
Administrator should have sufficient permissions.

Any thoughts would be appreciated.
Mike

Dim openDS As ActiveDs.IADsOpenDSObject
Dim usr As ActiveDs.IADsUser

Dim dso
Dim userName As String
Dim password As String

'--bind using Windows principal
userName = "Administrator"
password = "password"

openDS = GetObject("LDAP:")
dso = openDS.OpenDSObject( _
"LDAP://localhost:50000/OU=Dev,O=BJ,C=US", _
userName, _
password, _
ADS_SECURE_AUTHENTICATION + ADS_SERVER_BIND)

'--create a new user
usr = dso.Create("user", "CN=jdoe")
usr.Put("cn", "John")
usr.Put("sn", "Doe")
usr.SetInfo() '<<-- fails here with 80072032,
"invalid dn syntax"
 
The problem is that you have instantiated the object in memory with

usr = dso.Create("user", "CN=jdoe")

so the object reference is cn=jdoe and then you try and change the CN
(essentially renaming it) before the object has been written to the
directory.

Just create the object with the CN that you want it to have e.g.
usr = dso.Create("user", "CN=John)
and drop
usr.Put("cn", "John")

Lee Flight
 
Back
Top