Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Pulling AD EmployeeID attribute via SQL Server

Posted on 2010-09-21
12
Medium Priority
?
967 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 59

Expert Comment

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

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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
LVL 59

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
 
LVL 59

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

721 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