Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Query LDAP server from SQL Server Expand / Collapse
Author
Message
Posted Friday, February 4, 2011 12:31 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, September 7, 2014 11:36 AM
Points: 1, Visits: 117
Hello,

I was recently experiencing this same issue for a Cross-Forest Two-Way Trust and the solution was to create a Local Domain User Account in the other Domain and use a Linked Server specifically for Non-Local Domains.

First, SQL Server 2005 is more restrictive from a Security Perspective. So, on the Security page of the Linked Server Properties, you must Select the 'Be made using the security context:' Radio button and enter a Domain User Account in one of the following forms ADSIUSER@DOMAIN.COM or DOMAIN\ADSIUSER into the 'Remote Login:' field, and the password for the User into the 'With password:' field.

I.E. Local Domain is LOCAL.COM and the user account specified in the Linked Server is: LOCAL\ADSILOC, the External Domain to query via ADSI is TEST.COM. I received the following:

'Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "ADSDSOObject" for linked server "ADSILOC" 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 1
An error occurred while preparing the query "%ADSIQUERY%" for execution against OLE DB provider "ADSDSOObject" for linked server "ADSILOC". for this Linked Server.'

When I changed the Credentials to TEST\ADSITST, the Linked Server was able to query ADSI.

SQL Server does not seem to pass permissions cross-domain well, using a Local Domain User Account for each Forest we connect to has resolved our issue.
Post #1058953
Posted Thursday, May 12, 2011 9:15 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, January 2, 2014 7:30 AM
Points: 37, Visits: 220
I got your example to work when I'm physically on the server, but when I try it from my workstation, I get:

An error occurred while preparing the query "SELECT * FROM 'LDAP://NOVMDC02.SD.INT' where objectClass = 'User' " for execution against OLE DB provider "ADsDSOObject" for linked server "(null)".

I assume it's some sort of security issue.

Any and all ideas are welcome.



Post #1107802
Posted Thursday, May 12, 2011 9:21 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, January 2, 2014 7:30 AM
Points: 37, Visits: 220
Most - if not all - security issues are supposedly resolved if Kerberos is implemented.
Which is not the case where I work.
Post #1107807
Posted Tuesday, May 24, 2011 7:02 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, October 28, 2011 2:02 PM
Points: 71, Visits: 306
Peter Pirker (5/12/2011)
I got your example to work when I'm physically on the server, but when I try it from my workstation, I get:
An error occurred while preparing the query "SELECT * FROM 'LDAP://NOVMDC02.SD.INT' where objectClass = 'User' " for execution against OLE DB provider "ADsDSOObject" for linked server "(null)".

I assume it's some sort of security issue.


Same exact behavior here, works fine if I remote onto the server where Linked Server is set up. I was thinking it was like a double hop issue.



Post #1113978
Posted Tuesday, May 24, 2011 7:12 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, March 23, 2012 10:11 AM
Points: 6, Visits: 49
I'm able to query LDAP from our SSRS server as well as directly from our SQL Server. I haven't tried it from any workstation.
Post #1113993
Posted Thursday, July 28, 2011 1:48 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, June 21, 2012 3:22 PM
Points: 1, Visits: 4
THIS WORKS FOR ME :

DECLARE @Application TABLE (cn varchar(50));
DECLARE @ApplicationCN varchar(50);
DECLARE @SQLString nvarchar(MAX);
DECLARE @Role varchar(50) = 'xxx';
DECLARE @ApplicationName varchar(50) = 'aaa';

SET @SQLString='SELECT cn FROM OPENQUERY(ADSI,''SELECT cn FROM ''''LDAP://prod.edframework.com''''
WHERE objectClass=''''msDS-AzApplication'''' AND msDS-AzApplicationName='''''+@ApplicationName+''''''')';
INSERT @Application EXEC(@SQLString);
SET @ApplicationCN=(SELECT TOP 1 cn FROM @Application);

SET @SQLString='SELECT givenName,sn,samAccountName,cn FROM OPENQUERY(ADSI,''SELECT cn FROM ''''LDAP://prod.edframework.com''''
WHERE msDS-MembersForAzRoleBL=''''CN='+@Role+',CN=AzRoleObjectContainer-'+@ApplicationCN+',CN='+@ApplicationCN+
',CN=US,OU=EDFrameworkAuthorizationStores,DC=prod,DC=edframework,DC=com'''''')'

PRINT (@SQLString);
Post #1150538
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse