Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2007
    Posts
    9

    Unanswered: OpenQuery, Active Directory, single quote problem

    This is not your standard single quote to double quote problem (i think )...

    The issue occurs when I am trying to query Active Directory using openquery and the group I am using to filter against has a single quote in the name...

    select *
    from openquery(ADSI, 'SELECT *
    FROM ''LDAP://DC=FTITools,DC=Com''
    WHERE MemberOf=''LDAP://CN=O'Brien,OU=Test,DC=Domain,DC=com''')

    NOTE: "ADSI" is our Active Directory Services 2.5 linked server

    Syntactically, if I remove the single quote from "O'Brien", the query runs successfully, just no results are returned, which validates the syntax of the overall statement. The single quote though is preventing me from being able to run this specific query. I have tried to escape the single quote with a forward slash, backward slash, etc. I just haven't been able to figure out how to do that correctly. Any help is appreciated.

    Thanks.

  2. #2
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696
    You have to play around with the quotes, you'll eventually get it.

    select *
    from openquery(ADSI, 'SELECT *
    FROM ''LDAP://DC=FTITools,DC=Com''
    WHERE MemberOf=''LDAP://CN=O''Brien,OU=Test,DC=Domain,DC=com''')
    Last edited by PMASchmed; 01-13-09 at 11:22.

  3. #3
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696
    Last post won't work, I think you may have to use quoted identifiers.

  4. #4
    Join Date
    Jan 2007
    Posts
    9
    Unfortunately, that fix does not work in this context but thank-you for the response nonetheless.

  5. #5
    Join Date
    May 2014
    Posts
    1

    i have the exact same issue

    Hi has anyone come up with a solution for this problem? Funnily enough i have the exact same issue with the exact same name O'Brien...
    Any help would be great!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •