[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

DN of user from their Employee ID

Posted on 2011-03-02
12
Medium Priority
?
1,227 Views
Last Modified: 2012-05-11
I am looking for a PowerShell script to get the DN of a user from the users employeeID.

I have tried several Ldap Filters:
get-qaduser -LdapFilter "(&(!employeeID=*))" -IncludedProperties employeeID
This returns all users even those with a null employeeID.

I have tried variations by adding and removing the & and the !.

Some of these do not return errors, but they also do not return any data either.

Need a little help

Thanks
0
Comment
Question by:Runchr
[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
  • 4
  • 4
  • 2
  • +1
12 Comments
 
LVL 11

Expert Comment

by:Tasmant
ID: 35020262
To get all users where the EmployeeID attribute is set to any value, try this:
get-qaduser -LdapFilter "(&(employeeID=*))"

I don't think your need to the IncludedProperties switch to get DN only
0
 
LVL 11

Expert Comment

by:RickSheikh
ID: 35020295
using the exclamation in the ldapfilter, you are telling it to give you the accounts where the employeeid does not exist.

get-qaduser -LdapFilter "(&(employeeID=*))" -sl 0 | select name,dn

0
 
LVL 27

Expert Comment

by:KenMcF
ID: 35020297
Try this

get-qaduser -LdapFilter "(employeeID=*)" -IncludedProperties employeeID | Select Name, DN, EmployeeID | Export-csv c:\users.csv
0
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 

Author Comment

by:Runchr
ID: 35020377
Tasmut,

I got that, what I want is the DN of a specific user
0
 
LVL 11

Expert Comment

by:RickSheikh
ID: 35020425
Based off of his/her employeeid ?

get-qaduser -LdapFilter "(employeeID=123456789)"  | Select Name, DN,

0
 
LVL 11

Expert Comment

by:Tasmant
ID: 35020595
Asterisk is a special meaning in LDAP filter to represent "all". if you have some users where EmployeeID has the value " * ", then you need to represent this by escaping the *:
get-qaduser -LdapFilter "(employeeID=\2A)"  | Select Name, DN

or simply follow RickSheikh suggestion, as well as KenMcF
0
 

Author Comment

by:Runchr
ID: 35020809
Tasmant,

Thanks for the help, but none of these seem to work.  I do not get errors nor results.
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 35020955
Are you sure you are using the employeeID attribute to store this information in? Try to run this on a user account that you know has an employee ID entered to verify the attribute you are searching for.

get-qaduser USERNAME -includedproperties * | FL *
0
 

Accepted Solution

by:
Runchr earned 0 total points
ID: 35022434
This is what I ended up using:

$objUser = Get-QADuser -sizelimit 0 -ldapfilter "(&(objectCategory=person)(objectClass=user)(employeeID=1))"
$DN = $objUser.DN
$DN

Funny thing is it did not work in PowerGUI, but is Quick Connect it ran fine.

Thanks to all
0
 
LVL 11

Expert Comment

by:RickSheikh
ID: 35022575
That is rather a longer  way to accomplish something so simple.

If I have a user whose user ID is 1 and I want its DN. Following one liner is sufficient in PowerShell console or PowerGUI

get-qaduser -LdapFilter "(employeeID=1)"  | Select Name, dn
0
 
LVL 11

Expert Comment

by:RickSheikh
ID: 35022588
I meant to say "whose employeeID is 1"
0
 

Author Closing Comment

by:Runchr
ID: 35067780
This works
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
How to deal with a specific error when using the Enable-RemoteMailbox cmdlet to create a mailbox in the cloud-based service, for an existing user in an on-premises Active Directory.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
Suggested Courses

656 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