Solved

Pulling AD EmployeeID attribute via SQL Server

Posted on 2010-09-21
12
959 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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 …
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

805 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