Petri.com forums Home Forums Start Page Forums Frequently Asked Questions FAQ Member List Members List
Go Back   Petri IT Knowledgebase Forums > Server Operating Systems > Windows Server 2000 / 2003 / 2003 R2
Petri.com is happy to award RicklesP the title of Most Valuable Member !!!
Register Calendar Calendar Search Petri IT Knowledgebase Forums Search Todays Posts Today's Posts Mark Forums Read
Notices

how to find users distinguished name of users in AD?

how to find users distinguished name of users in AD?

this thread has 7 replies and has been viewed 97257 times

Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1  
Old 15th July 2008, 17:49
mehdix's Avatar
mehdix mehdix is offline
Casual
Casual
 
 Join Date: Jul 2008
  6 month star 12 month star
 Location: Tehran
 Posts: 30
  Send a message via MSN to mehdix Send a message via Yahoo to mehdix
 Reputation: mehdix is an unknown quantity at this point (7)
Exclamation how to find users distinguished name of users in AD?

hey everyone,
i exported the enabled user list from AD with LDAP query, but i need each user's distinguished name for moving into a new Network and creating all these users in my new AD.
i have 390 users so i realy need some help!!!
  #2  
Old 15th July 2008, 19:49
Garen Garen is offline
Users Awaiting Email Confirmation
Someone to look up to
 
 Join Date: Nov 2007
  6 month star 12 month star
 Posts: 751
 Reputation: Garen will become famous soon enoughGaren will become famous soon enough (147)
Default Re: how to find users distinguished name of users in AD?

"dsquery user > c:\dn.txt"
  #3  
Old 15th July 2008, 20:36
Rems's Avatar
Rems Rems is offline
Moderator
 
 Join Date: Mar 2005
  6 month star 12 month star
 Location: NL
 Posts: 2,433
 Reputation: Rems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to behold (965)
Default Re: how to find users distinguished name of users in AD?

yes you can use dsquery (help: dsquery.exe /?)

To filter all disabled users out..
copy the ldap-filter string from your 'saved query' and use it with dsquery -filter:
Code:
DSQUERY.exe * -limit 0 -filter "(&(objectCategory=Person)(objectClass=User)(!userAccountControl:1.2.840.113556.1.4.803:=2))" >"c:\activeUsers.txt"
\Rems
__________________

This posting is provided "AS IS" with no warranties, and confers no rights.

__________________

** Remember to give credit where credit's due **
and leave Reputation Points for meaningful posts
  #4  
Old 15th July 2008, 21:21
L4ndy L4ndy is offline
Moderator
 
 Join Date: May 2006
  6 month star 12 month star
 Location: Liverpool, UK
 Posts: 2,634
 Reputation: L4ndy is a glorious beacon of lightL4ndy is a glorious beacon of lightL4ndy is a glorious beacon of lightL4ndy is a glorious beacon of lightL4ndy is a glorious beacon of lightL4ndy is a glorious beacon of light (541)
Default Re: how to find users distinguished name of users in AD?

This one has worked for me just fine:

Code:
dsquery user -limit 1000 | dsget user -dn >C:\Getuserdn.txt
Since you only have 390 users I'd leave the limit as it is otherwise replace with the right value.

Cheers
__________________
Caesar's cipher - 3

ZKHQ BRX HYHQWXDOOB GHFLSKHU WKLV BRX ZLOO UHDOLVH LW ZDV D ZDVWH RI WLPH!

SFX JNRS FC U6 MNGR
  #5  
Old 16th July 2008, 00:55
guyt's Avatar
guyt guyt is offline
[MSFT]
Guru
 
 Join Date: Nov 2003
  6 month star 12 month star
 Location: Israel
 Posts: 1,766
  Send a message via MSN to guyt
 Reputation: guyt is a name known to allguyt is a name known to allguyt is a name known to allguyt is a name known to allguyt is a name known to allguyt is a name known to all (592)
Default Re: how to find users distinguished name of users in AD?

Quote:
Originally Posted by L4ndy View Post
This one has worked for me just fine:

Code:
dsquery user -limit 1000 | dsget user -dn >C:\Getuserdn.txt
This will return ALL the user accounts including disabled accounts.
__________________
Guy Teverovsky
http://blogs.technet.com/b/isrpfeplat/
"Smith & Wesson - the original point and click interface"
  #6  
Old 16th July 2008, 13:14
L4ndy L4ndy is offline
Moderator
 
 Join Date: May 2006
  6 month star 12 month star
 Location: Liverpool, UK
 Posts: 2,634
 Reputation: L4ndy is a glorious beacon of lightL4ndy is a glorious beacon of lightL4ndy is a glorious beacon of lightL4ndy is a glorious beacon of lightL4ndy is a glorious beacon of lightL4ndy is a glorious beacon of light (541)
Default Re: how to find users distinguished name of users in AD?

Quote:
Originally Posted by guyt View Post
This will return ALL the user accounts including disabled accounts.
Yeah, you right, completely missed that bit.
Plus looking at it more in depth at my code you dont even need to Pipe it to Dsget if the output it's going to be a txt file.
So REMS suggestion should do just fine. ( Not that I was ever in doubt but I wasn't getting it!)

Thanks
__________________
Caesar's cipher - 3

ZKHQ BRX HYHQWXDOOB GHFLSKHU WKLV BRX ZLOO UHDOLVH LW ZDV D ZDVWH RI WLPH!

SFX JNRS FC U6 MNGR
  #7  
Old 17th July 2008, 13:10
L4ndy L4ndy is offline
Moderator
 
 Join Date: May 2006
  6 month star 12 month star
 Location: Liverpool, UK
 Posts: 2,634
 Reputation: L4ndy is a glorious beacon of lightL4ndy is a glorious beacon of lightL4ndy is a glorious beacon of lightL4ndy is a glorious beacon of lightL4ndy is a glorious beacon of lightL4ndy is a glorious beacon of light (541)
Default Re: how to find users distinguished name of users in AD?

However, you could avoid doing the LDAP query step altogether if you run the following command against AD:
Code:
dsquery user -limit 0 | dsget user -dn -disabled >C:\getalluserdn.txt
It'll create a file with all te users DN on it together with the Disabled status.
The -Disabled parameter will return a value of Yes and No.
You can then export the file into Excel and select only the records with a No value.
You can then use the selected data to go to the next step of using DSadd user if you plan to have the same Ou structure in your new AD.

Cheers
__________________
Caesar's cipher - 3

ZKHQ BRX HYHQWXDOOB GHFLSKHU WKLV BRX ZLOO UHDOLVH LW ZDV D ZDVWH RI WLPH!

SFX JNRS FC U6 MNGR
  #8  
Old 18th July 2008, 19:00
mehdix's Avatar
mehdix mehdix is offline
Casual
Casual
 
 Join Date: Jul 2008
  6 month star 12 month star
 Location: Tehran
 Posts: 30
  Send a message via MSN to mehdix Send a message via Yahoo to mehdix
 Reputation: mehdix is an unknown quantity at this point (7)
Default Re: how to find users distinguished name of users in AD?

Thanks alot guys
it Works fine for me Rems thank u !
Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OWA Premium cannot find users in GAL nvarsovia Exchange 2000 / 2003 6 4th December 2007 22:26
An easy way to find out how many users have mailboxes? tnshurtm Exchange 2000 / 2003 2 7th December 2006 23:29
find users who didnt log on king72 Active Directory 1 3rd December 2006 01:02
LDAP query o find users that did not logon since 31/12/05. znme Active Directory 2 8th July 2006 20:58
How to find th AD users accounts? ermal Active Directory 1 6th June 2005 09:09


All times are GMT +3. The time now is 03:36.

Steel Blue 3.5.4 vBulletin Style ©2006 vBEnhanced
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
 

Valid XHTML 1.0!   Valid CSS!

Copyright 2005 Daniel Petri