OLE DB and Microsoft Directory Services

  • Has anyone ever configured a linked server to use ADSI, and successfully queried the AD with SQL Query Analyser ?

    There is an article in BOL about how to create such a linked server. (And a sample query)

    I have tried everything (experimented, researched in MSoft, Web, usenets) and all I ever get is:

    Server: Msg 7321, Level 16, State 2, Line 1

    An error occurred while preparing a query for execution against OLE DB provider 'ADSDSOObject'.

    OLE DB error trace [OLE/DB Provider 'ADSDSOObject' ICommandPrepare:repare returned 0x80040e14].

    Is this some sort of extended April Fools joke ?

    David.


    The systems fine with no users loggged in. Can we keep it that way ?br>

  • Ugh...  yeah, I've tried a couple times to find information on how to create a linked server to active directory services.  It would be nice to be able to query the active directory user list and get details about employees through there.

    but... sadly, I've had no luck in this.  Maybe someone smarter than me will figure this one out and post here.

  • I have had some success with these two queries

    SELECT *

    FROM OpenQuery( ADSI,'<GC://xxx.co.uk>;(&(objectCategory=person)(objectClass=user));cn,distinguishedName,name,givenName,sn,sAMAccountName,department,mail,adspath;subtree')

    SELECT cn,distinguishedName,name,givenName,sn,sAMAccountName,department,mail,adspath

    FROM OPENQUERY(ADSI,

    'SELECT cn,distinguishedName,name,givenName,sn,sAMAccountName,department,mail,adspath

    FROM ''LDAP://servername'' WHERE objectCategory = ''CN=Person,CN=Schema,CN=Configuration,DC=xxx,DC=co,DC=uk'' AND objectClass= ''user''')

    The big problem I found is that ADSI returns byte arrays as variants for some data and this causes sql many problems.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Interesting, David - thanks.

    I found this on the Web - it helps.

    http://www.nerva.com/computing/CodeSamples/ADSI_SQL_Example.htm

    DB


    The systems fine with no users loggged in. Can we keep it that way ?br>

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply