May 6, 2015 at 12:07 pm
I have very unusual question. I have seen a query that looks something like this:
SELECT A, B, C FROM 'LDAP://abc.def.com'
What exactly does this mean? Could such a query be executed in the SQL Server Management Studio? Where would such a table/database be actually located?
May 6, 2015 at 2:50 pm
One bit of information, this query is used to read the active directory.
May 7, 2015 at 12:25 pm
This link below gave me some ideas when I was putting together a query.
http://stackoverflow.com/questions/407671/query-ad-from-sql-server-2005
This is a query I actually got to work at my place, what I found interesting is that selecting with a '*' instead of an explicit column list returned entirely different stuff whereas I expected the '*' would just send back all columns, but instead it returned a list of ldap urls, which makes me think SQL Server actually passes the query through to the ldap / ad server with much less processing than I would have figured (in other words, * does NOT mean all the columns in this case). But the (commented) select with the list of columns also worked and returned the three columns as expected.
SELECT top 100 *
--SELECT top 100 [Name], SN [Last Name], ST State
FROM OPENQUERY( ADSI,
'SELECT *
FROM ''LDAP://a_local_active_directory_server''
WHERE objectCategory=''user''
')
edit: I also had to add in a linked server, forgot to add this!
EXEC sp_addlinkedserver 'ADSI', 'Active Directory Services Interfaces','ADSDSOObject', 'adsdatasource'
The version with the explicitely named columns:
SELECT top 100 [Name], SN [Last Name], ST State
FROM OPENQUERY( ADSI,
'SELECT Name, SN, ST
FROM ''LDAP://active_directory_server''
WHERE objectCategory=''user''
')
May 8, 2015 at 3:55 pm
thank you for the explanation. I did not pick up on the linked server. I suppose the linked server connect to the active directory data store against which the query is running.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy