Strange Problems with LDAP and Active Directory

I’m experiencing some strange problems coding in LotusScript when I am dealing with LDAP and Active Directory (AD) access. Here are parts of the code:


  1. sADsPath = “LDAP://ou=XXX Groups,DC=xxx,DC=xyz,DC=com,DC=au”

2 Set oLDAP = GetObject(“LDAP:”)

  1. Set oOU =

oLDAP.OpenDSObject(sADsPath,“userid”,“xxxxxxxx”,ADS_SECURE_AUTHENTICATION)

  1. Set oGroup = oOU.Create(“Group”,“cn=” & p_sGroup)

  2. oGroup.Put “sAMAccountName”,p_sGroup

  3. oGroup.Put “groupType”,ADS_GROUP_TYPE_LOCAL_GROUP +

ADS_GROUP_TYPE_SECURITY_ENABLED

  1. oGroup.SetInfo

It seems to occur everytime I invoke the Put() method of an AD group object. When I invoke the method and pass in a string variable as shown in Example 1, I get an error 213 and an error message of “OLE: Automation object error” on execution of the Put() method.

Example 1:

Dim sGroup As String

sGroup = “XXX”

oGroup.Put “sAMAccountName”,sGroup

However, everything works correctly if I pass in the information as a hard coded string, a string constant, or have the variable declared as a variant instead of a string as shown in Example 2.

Example 2:

Dim vGroup As Variant

vGroup = “XXX”

oGroup.Put “sAMAccountName”,vGroup

As a question of curiosity, can anybody explain to me why the Put() method is throwing errors when I pass in a string variable as an argument?

Subject: Strange Problems with LDAP and Active Directory

I just came across the same problem. In case anyone else has the same issue you get around it by putting Cstr() around the variable name, so use:

oGroup.Put “sAMAccountName”, Cstr(sGroup)

I have no idea why!

Julie