locked
Query to LDAP using SQL Server 2008 RRS feed

  • Question

  • User676520890 posted

    Hi,


    I am trying to write a query to get the data from LDAP using SQL server. 

    LDAP server is residing on my company's server and SQL Server is located on my local PC. Though the services are logged in as NT/NETWORKSERVICES


    EXEC sp_addlinkedserver 'ADSI3', 'Active Directory Services 2.5', 
    'ADSDSOObject', 'adsdatasource'
    GO
    exec sp_addlink
    EXEC sp_addlinkedsrvlogin 'ADSI', false, NULL, 
    'uid=edeplex,ou=users,ou=internal,o=Ericsson', '@WSX4rfv' 
    sp_configure 'show advanced options', 1
    reconfigure with override
    GO
    sp_configure 'Ad Hoc Distributed Queries', 1 
    reconfigure
    SELECT * FROM OpenQuery(ADSI, 'SELECT  displayName  FROM 
    ''LDAP://ecd.ericsson.se:389;uid=edulbud''  where ou=''EUS'' and Departmentnumber=''W*'' ' )

    EXEC sp_addlinkedserver 'ADSI', 'Active Directory Services 2.5', 

    'ADSDSOObject', 'adsdatasource'

    GO


    -- Add Login

    -- the user name to use in LDAP is  'uid=eabcde,ou=users,ou=internal,o=xxxx

    -- password is  C*C*C*C*


    EXEC sp_addlinkedsrvlogin 'ADSI', false, NULL, 

    'uid=eabcde,ou=users,ou=internal,o=xxxx', 'C*C*C*C*' 


    -------------------------

    sp_configure 'show advanced options', 1

    reconfigure with override

    GO

    sp_configure 'Ad Hoc Distributed Queries', 1 

    reconfigure


    ---------------------Query

    SELECT * FROM OpenQuery(ADSI, 'SELECT  * FROM 

    ''LDAP://aaa.bbbb.se:389''  where ou=''EUS'' and Departmentnumber=''W*'' ' )


    this query works fine gives me only ADSPath as a result. I want DisplayName, Mail and employeeNumber from LDAP


    but when i try to write 


    SELECT * FROM OpenQuery(ADSI, 'SELECT  displayName,mail,employeenumber  FROM 

    ''LDAP://aaa.bbbb.se:389''  where ou=''EUS'' and Departmentnumber=''W*'' ' ) 


    it gives me an error that 

    "The OLE DB provider "ADSDSOObject" for linked server "ADSI" reported an error. The provider did not give any information about the error. "


    Can anyone please help me with this  issue ?


     

    Tuesday, July 13, 2010 5:51 PM

Answers

  • User15685074 posted

    This really is not the right place for this question.  You should take a look at the SQL Server forums.

    MODERATOR: Suggest we move or close if possible (not related to ASP.NET, MSSQL Server Only) 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 18, 2010 1:20 AM