Petri.com forums Home Forums Start Page Forums Frequently Asked Questions FAQ Member List Members List
Go Back   Petri IT Knowledgebase Forums > Microsoft Networking Services > Active Directory
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

listing all users and their email address

listing all users and their email address

this thread has 7 replies and has been viewed 30925 times

Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1  
Old 19th September 2007, 09:38
hammo hammo is offline
Casual
Casual
 
 Join Date: Mar 2005
  6 month star 12 month star
 Posts: 48
 Reputation: hammo is on a distinguished road (23)
Default listing all users and their email address

Hi,

I need to get a list of every user account and its corresponding email address from AD.

I've tried using the ADUC find tool with a combination of options and I can get a list of every user and their email address... but I cant export this information!

So I've been having a look at dsquery/dsget and adfind but im having a bit of trouble with the syntax. anyone able to point me in the right direction?

I need to pull out every user in the domain, their corresponding email address and export it to CSV.

cheers!
  #2  
Old 19th September 2007, 10:08
Daxxian Daxxian is offline
Casual
Casual
 
 Join Date: Sep 2007
  6 month star 12 month star
 Location: Okinawa, JP
 Posts: 5
 Reputation: Daxxian is on a distinguished road (11)
Default Re: listing all users and their email address

I have had to do this a lot. I am new to this forum thing, so I don't know if I am being Mr. Obvious, But have you tried "csvde -f stuff.csv" from your domain controller. Read the help to see how to narrow down the output to a given OU or object class with -d or -r. Its fun, easy, and you can learn a lot about user attributes from the 56 column excel document it exports. Good luck.
  #3  
Old 19th September 2007, 13:49
Rems's Avatar
Rems Rems is offline
Moderator
 
 Join Date: Mar 2005
  6 month star 12 month star
 Location: NL
 Posts: 2,431
 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: listing all users and their email address

If you have Windows Server 2003, you use the tools in 'Saved Queries' to create the query. http://www.petri.com/saved_queries_i...s_2003_dsa.htm

Finish your 'saved query' in ADU&C. Then with 'Edit', you can select and copy the query string;
It will be something simular like this;
(&(objectCategory=person)(objectClass=user)(mail=* ))

You can use the 'filter' above with DSQUERY
Start | Run:
Code:
cmd /c dsquery.exe * -limit 0 -filter "(&(objectCategory=person)(objectClass=user)(mail=*))" -attr name mail >"c:\PrimaryEmailAddresses.txt"
After hitting the Enter key a new file will be created containing each user's fullname and primary emailaddress.

About the same results you can get when using CSVDE:
Start | Run:
Code:
cmd /c csvde.exe -r "(&(objectCategory=person)(objectClass=user)(mail=*))" -l name,mail -f "c:\PrimaryEmailAddresses.csv"
(skip cmd /c if you are running the command-line from a dos prompt)

more tools:
LDAP Query Basics


Daxxian gave an excellent tip how to study the Attributes. You have to know them for the output. There for in the dsquery example replace -attr name,mail with -attr * to output all the attributes of the user objects. In csvde skip -l name,mail .


\Rems

Last edited by Rems; 19th November 2007 at 14:17..
  #4  
Old 20th September 2007, 02:14
hammo hammo is offline
Casual
Casual
 
 Join Date: Mar 2005
  6 month star 12 month star
 Posts: 48
 Reputation: hammo is on a distinguished road (23)
Default Re: listing all users and their email address

thanks very much people!

thats exactly what I was after - now I know how to pull all sorts of data out..

cheers
dave
  #5  
Old 19th November 2007, 23:43
hasdou hasdou is offline
Casual
It's not a coincidence
 
 Join Date: Nov 2007
  6 month star 12 month star
 Location: Tel-Aviv
 Posts: 81
 Reputation: hasdou is on a distinguished road (33)
Default Re: listing all users and their email address

very nice solutions but I have a problem with each one of them :

dsquery.exe -> the output text file is encodded ANSI and I need RTF
Is it possible to change encoding ?

csvde.exe -> the csv output file is made by 1 column of oll the data
Is it possible to fraction the result by column ? (example : A column is name, B is email ...) ?
  #6  
Old 20th November 2007, 01:42
Rems's Avatar
Rems Rems is offline
Moderator
 
 Join Date: Mar 2005
  6 month star 12 month star
 Location: NL
 Posts: 2,431
 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: listing all users and their email address

Quote:
dsquery.exe -> the output text file is encodded ANSI and I need RTF
Is it possible to change encoding ?
No, but you can fake it by changing the extension.
But, why direct into RTF??? (I don't see the advantage).


Quote:
csvde.exe -> the csv output file is made by 1 column of oll the data
Is it possible to fraction the result by column ?
'CVS' in csvde = 'Comma Separated Value'. Open this filetype with excel to show the separated values in columns.

If you want to create a 'Rich Text Format' file, use vbscript.
Take this example.
http://forums.petri.com/showpost.php...46&postcount=4
This still export in ascii, but when you change the extension to rtf AND add the "enRiching"-code in the script this becomes a real RTF-file,
- http://www.freevbcode.com/ShowCode.Asp?ID=6326
- http://www.biblioscape.com/rtf15_spec.htm


\Rems
  #7  
Old 20th November 2007, 07:26
hasdou hasdou is offline
Casual
It's not a coincidence
 
 Join Date: Nov 2007
  6 month star 12 month star
 Location: Tel-Aviv
 Posts: 81
 Reputation: hasdou is on a distinguished road (33)
Default Re: listing all users and their email address

thank you for answering.

1) I need rtf encoding for hebrew language purposes.
2) i would like separeted values for automatisation of other scripts based on this output file.

I'll try.

10x once more.
  #8  
Old 20th November 2007, 15:14
Rems's Avatar
Rems Rems is offline
Moderator
 
 Join Date: Mar 2005
  6 month star 12 month star
 Location: NL
 Posts: 2,431
 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: listing all users and their email address

Glad I could help.

You can create a sample RTF file with Wordpad.exe in your language.
Then open the file with Notepad.exe to see the code.

\Rems
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
Default Email address for new users spepi Exchange 2000 / 2003 4 27th December 2006 21:03
Strange LDAP email address users texastig SBS 2000 / 2003 1 18th March 2006 01:43
Users email address is truncated when replying awillholt Exchange 2000 / 2003 4 21st October 2005 15:44
Print out of users email address from MS Exchange or AD poweredge4000 Exchange 2000 / 2003 4 1st July 2005 12:51
Exchange Address Name Listing? liamw Exchange 2000 / 2003 1 22nd October 2004 20:13


All times are GMT +3. The time now is 00:02.

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