Error connecting LDAP Server to SQL Server 2008

  • Hi,

    When I use the following code I get an error:

    declare @linkedServerSql nvarchar(4000),

    @linkedServerName varchar(100),

    @localSqlUsername varchar(100),

    @domainUsername varchar(100),

    @domainUserPassword varchar(100)

    -- Set the local sql server user

    set @localSqlUsername = 'sa'

    -- format can be 'domainName\userName' or 'userName@domainName'

    set @domainUsername = 'mellds01\Administrator'--tried as admin,admimistrator and uid=admin,ou=system

    set @domainUserPassword = 'password'

    set @linkedServerName = 'adsi'

    set @linkedServerSql = ' exec sp_addlinkedserver ''' + @linkedServerName + ''','''', ''ADSDSOObject'', ''''

    exec sp_addlinkedsrvlogin ''' + @linkedServerName + ''', false, ''' + @localSqlUsername + ''',

    ''' + @domainUsername + ''', ''' + @domainUserPassword + ''''

    exec sp_executesql @linkedServerSql

    select * from openquery(adsi,'select cn from ''LDAP://dc=racs,dc=org'' where objectClass = ''USER'' ')

    Msg 7399, Level 16, State 1, Line 2

    The OLE DB provider "ADSDSOObject" for linked server "adsi" reported an error. The provider indicates that the user did not have the permission to perform the operation.

    Msg 7321, Level 16, State 2, Line 2

    An error occurred while preparing the query "select cn from 'LDAP://dc=racs,dc=org' where objectClass = 'USER' " for execution against OLE DB provider "ADSDSOObject" for linked server "adsi".

  • I would suggest reading http://social.msdn.microsoft.com/Forums/en-US/sqlsecurity/thread/91f3ef67-6c84-4774-a7aa-c8e8be014721/ as there is specific information about troubleshooting steps when encountering this error.

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

Viewing 2 posts - 1 through 1 (of 1 total)

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