Solved

Pulling AD EmployeeID attribute via SQL Server

Posted on 2010-09-21
12
962 Views
Last Modified: 2012-05-10
Hi, I am trying to pull AD data into SQL and I've got everything working except for the employeeID attribute.  I can't get the employeeid values to populate into SQL.  Does anyone have any ideas on why this is not working?  I have attached my code.
SELECT     TOP (100) PERCENT displayName, mobile, facsimiletelephoneNumber, telephoneNumber, mail, department, physicalDeliveryOfficeName, title, givenName, 
                      employeeid
FROM         OPENQUERY(AD, 
                      '
select  givenName,title,
    physicalDeliveryOfficeName,
    department, mail,
    telephoneNumber,  facsimiletelephoneNumber,
    mobile, 
    displayName, employeeid
    
from    ''LDAP://ausdc2:3268/ OU=Dynamic Systems,  DC=fgi_main,DC=local''
where objectCategory = ''Person''  
        and  
         objectClass = ''user'' 

')
                       AS Rowset_1
WHERE     (givenName IS NOT NULL)
ORDER BY displayName

Open in new window

0
Comment
Question by:imstac73
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 2
12 Comments
 
LVL 51

Expert Comment

by:Huseyin KAHRAMAN
ID: 33729505
do you get null in the result?
0
 
LVL 51

Expert Comment

by:Huseyin KAHRAMAN
ID: 33729508
do you have employeeid in LDAP?

do you have any other tool to query LDAP, and from that tool, do you get employeeid?
0
 

Author Comment

by:imstac73
ID: 33729509
Yes
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 51

Expert Comment

by:Huseyin KAHRAMAN
ID: 33729516
whats is so special for employeeid in LDAP? do you see any difference between employeeid & other fields?
0
 

Author Comment

by:imstac73
ID: 33729538
I don't know. I don't deal with the AD side at all; only SQL.  
0
 

Author Comment

by:imstac73
ID: 33729544
My AD guy was able to query the employeeid using another tool and the data is there.
0
 
LVL 51

Expert Comment

by:Huseyin KAHRAMAN
ID: 33729571
is it one value or multiple values? what happens if you use empid instead of employeeid
does it crash or give null again...
0
 

Author Comment

by:imstac73
ID: 33729600
It gives an error if I use empid.
0
 

Expert Comment

by:afinneran
ID: 33729719
Try ldp.exe to query AD. http://support.microsoft.com/kb/224543

If you google it you should find the download somewhere. Run it from your desktop and connect with your AD account and you should have rights to browse the AD tree. There may be more than one piece of data stored in the employeeid field and using ldp.exe will tell you what is in there. In general LDAP is case sensitive and you also need the full DN which can be hard to get sometimes.

Not sure from the SQL side but the user making the LDAP call also needs read rights to AD. Would you get an error if the authentication failed?
0
 

Author Comment

by:imstac73
ID: 33729894
I'm doubtful that it is permissions as I am able to pull other AD attributes.
0
 

Expert Comment

by:afinneran
ID: 33730116
Is employeeid in the same container (CN)and at the same level as the others?

displayName, mobile, facsimiletelephoneNumber, telephoneNumber, mail, department, physicalDeliveryOfficeName, title, givenName
0
 

Accepted Solution

by:
imstac73 earned 0 total points
ID: 33790432
Turns out that by changing the port number used in the connection to the domain controller server solved the problem.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question