Announcement

Collapse
No announcement yet.

listing all users and their email address

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Comment


    • #3
      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, 12:17.

      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

      Comment


      • #4
        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

        Comment


        • #5
          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 ...) ?

          Comment


          • #6
            Re: listing all users and their email address

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


            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

            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

            Comment


            • #7
              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.

              Comment


              • #8
                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

                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

                Comment

                Working...
                X