Solved

Pulling AD EmployeeID attribute via SQL Server

Posted on 2010-09-21
12
957 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
  • 6
  • 4
  • 2
12 Comments
 
LVL 51

Expert Comment

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

Expert Comment

by:HainKurt
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
 
LVL 51

Expert Comment

by:HainKurt
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 51

Expert Comment

by:HainKurt
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now