Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 [Resolved] Open Query selecting from LDAP

Author  Topic 

snufse
Constraint Violating Yak Guru

469 Posts

Posted - 2010-01-12 : 08:55:19
Have following (using linked server)

select  * 
from openquery(ADSI_10_xx_x_3, '
select title, sAMAccountName, displayName
from ''LDAP://DC=Vecelliogroup,DC=COM''
where objectClass = ''User''')


Query returns correct result:


displayname sAMAccountname Title

VGIBEW03-SMTP$ VGIBEW03-SMTP$ NULL
RGWPW03-TS$ RGWPW03-TS$ NULL
VGIWPPGP$ VGIWPPGP$ NULL

Now I would like to add to the "where" clause where title is not null like this:

select  * 
from openquery(ADSI_10_92_4_3, '
select title, sAMAccountName, displayName
from ''LDAP://DC=Vecelliogroup,DC=COM''
where objectClass = ''User'' and title IS NOT Null')


I have tried different ways but cannot seem to get the syntax correct (An error occurred while preparing the query)




webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-01-12 : 09:19:22
select *
from openquery(ADSI_10_xx_x_3, '
select title, sAMAccountName, displayName
from ''LDAP://DC=Vecelliogroup,DC=COM''
where objectClass = ''User''')
where title is not null


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

snufse
Constraint Violating Yak Guru

469 Posts

Posted - 2010-01-12 : 09:33:22
webfred, that worked. Thank you.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-01-12 : 10:09:22
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2010-01-15 : 16:06:30
I have a requirement to do something very similar.

Can someone point me to a resource that describes how to implement LDAP access to another server and database from Windows/SQL 2005?
Go to Top of Page
   

- Advertisement -