• Vortex (9/27/2007)


    Folks,

    I have the same problem here, but the solutions provided solved the problem... while running the query on the server.

    select * FROM OPENROWSET('ADSDSOObject',

    'adsdatasource;', 'SELECT cn, mail, co, distinguishedName, displayName

    FROM ''LDAP://myDomain.lan'' where objectClass = ''User'' ')

    If i try to run the same query using SSMS on any desktop accessing this server, I get this error:

    Msg 7321, Level 16, State 2, Line 1

    An error occurred while preparing the query "SELECT cn, mail, co, distinguishedName, displayName

    FROM 'LDAP://myDomain.lan' where objectClass = 'User' " for execution against OLE DB provider "ADSDSOObject" for linked server "(null)".

    If I try the other solution

    select * from openquery

    (ADSI,'SELECT name

    FROM ''LDAP://myDomain.lan''

    WHERE objectCategory = ''Person'' AND objectClass = ''user''')

    I get the same weird error people complain about:

    Msg 7321, Level 16, State 2, Line 1

    An error occurred while preparing the query "SELECT name

    FROM 'LDAP://myDomain.lan'

    WHERE objectCategory = 'Person' AND objectClass = 'user'" for execution against OLE DB provider "ADsDSOObject" for linked server "ADSI".

    Any clues? Thanx!

    You need to provide the domain context.

    You have LDAP://myDomain.lan

    It's going to be something like:

    LDAP://myDomain.lan/dc.myDomain,dc=lan

    If you want to be REALLY tricky, you can use a serverless bind, which is:

    LDAP://dc=myDomain,dc=lan

    This will pick the closest domain controller.

    Random Technical Stuff[/url]