简体   繁体   中英

LDAP OpenQuery returns only one column ADsPath

I have added my Domain Controller as a linked server to SQL Server in order to pull some data from active directory and populate my tables with it. After that, I have executed an OpenQuery to get the users list in my domain

SELECT * FROM OpenQuery(ADSI, 'SELECT * FROM ''LDAP://OU=SmallOU, DC=MyDOMAIN,DC=xx,DC=xx'' WHERE objectClass=''User'' ')

I have performed the query against a small OU since performing the query against the whole directory returned errors because of number of rows limitation

Surprisingly, the query returns only one column " ADsPath ", whereas I expected to get sAMAccount , Title , Last Name , .... ,etc.

在此处输入图片说明

I want to get all the users data, how can I do that?

The provider will not try to find out which attributes to retrieve, if you use the asterisk with the SQL syntax. Instead of SELECT * you must specify the attributes you want like SELECT sAMAccountName, sn, givenName .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM