none
Attempting to construct LDAP query with getobject fails when passing string RRS feed

  • Question

  • Hello.

    I have a very simple question. I am trying to pass a constructed LDAP string to getobject and it fails, but works otherwise.

    ldapStr = chr(34) & "LDAP://" & "CN=Security Group" & ",OU=Security Groups,OU=SomeOU,DC=subdomain,DC=domain,DC=com" & chr(34) Set objGroup1 = GetObject("LDAP://CN=Security Group,OU=Security Groups,OU=SomeOU,DC=subdomain,DC=domain,DC=com") Set objGroup2 = GetObject(ldapstr) objGroup1.GetInfo

    objGroup2.GetInfo

     

    "objGroup1.GetInfo" works, while objGroup2.GetInfo fails with "(null): Invalid Syntax". I have tried escaping using a backslash (\) before the commas and forward slashes but same thing. I was hoping someone might be able to explain why getObject is not allowing me to pass this string when connecting via LDAP.

    Thanks for your help.

    Friday, October 31, 2014 10:40 AM

Answers

  • Why are you adding extra quotes.  This is not DOS it is ADSI.

    ldapStr = "LDAP://CN=Security Group,OU=Security Groups,OU=SomeOU,DC=subdomain,DC=domain,DC=com"
    
    Set objGroup2 = GetObject(ldapstr)
    
    


    ¯\_(ツ)_/¯

    • Marked as answer by KCSteele Friday, October 31, 2014 10:53 AM
    Friday, October 31, 2014 10:47 AM

All replies

  • Why are you adding extra quotes.  This is not DOS it is ADSI.

    ldapStr = "LDAP://CN=Security Group,OU=Security Groups,OU=SomeOU,DC=subdomain,DC=domain,DC=com"
    
    Set objGroup2 = GetObject(ldapstr)
    
    


    ¯\_(ツ)_/¯

    • Marked as answer by KCSteele Friday, October 31, 2014 10:53 AM
    Friday, October 31, 2014 10:47 AM
  • Or this:

    strGroup="Security Group"
    ldapStr= "LDAP://CN=" & strGroup & ",OU=Security Groups,OU=SomeOU,DC=subdomain,DC=domain,DC=com"

    Just cat the strings.  Don't add extra quotes.


    ¯\_(ツ)_/¯

    Friday, October 31, 2014 10:49 AM
  • Thanks jrv, can't believe I didn't just try that. I guess I figured since the explicit ldap query has the double quotes I would have to add them to the string when passing it to getObject.
    Friday, October 31, 2014 10:54 AM
  • Thanks jrv, can't believe I didn't just try that. I guess I figured since the explicit ldap query has the double quotes I would have to add them to the string when passing it to getObject.

    Nope.  That I only ever needed with commandline utility calls.


    ¯\_(ツ)_/¯

    Friday, October 31, 2014 11:00 AM