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
Solved

Pulling AD EmployeeID attribute via SQL Server

Posted on 2010-09-21
12
961 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
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…

808 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