?
Solved

Extract All SMTP Addresses in Domain

Posted on 2004-08-04
5
Medium Priority
?
3,791 Views
Last Modified: 2008-01-09
need to extract all SMTP addresses in a Win 2k3 AD domain.  i can use CSVD edit to extract proxy addresses but the resulting format is not easy to export to a text file..  i need a way to export IDs in one colume of a an Excel, not the way this command does it:
          csvde -f ProxyAddressExport.csv -r (objectClass=user) -l proxyAddresses
 
please, i am only looking for answers that include all proxy/smtp addresses in one column.  it has to be done through native Windows tools, no 3rd party products.  


disclaimer:
i will not award points to memebers that do not fully give the answer.
stating "it cannot be done" is not an answer and you will not be awarded credit.
0
Comment
Question by:xxgenius
[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
  • 2
  • 2
5 Comments
 
LVL 21

Expert Comment

by:marc_nivens
ID: 11719475
I wrote a script a while back to do just this.  Copy the script below, paste it into notepad, and save as a .vbs.  When you launch it, it asks you for servername domain.  If you server is named DC1, and your domain was test.com, you would enter:  DC1/dc=test,dc=com

This will dump all users in the domain to an ldif formatted file that contains their proxy addresses.  You can use this ldif file to reimport later on if needed.





Const Writable       = 2

Set objFSO             = CreateObject("Scripting.FileSystemObject")
Set objLog            = objFSO.OpenTextFile("c:\proxydump.ldf", Writable, True)
Set cn                 = CreateObject("ADODB.Connection")
Set cm                  = CreateObject("ADODB.Command")
Set rs                  = CreateObject("ADODB.RecordSet")


With cn
      .Provider      = "ADsDSOObject"
      .Open "Active Directory Provider"
End With

Set cm.ActiveConnection = cn

strDomainDN            = InputBox("Please Enter the Servername and Domain DN. " & vbCrLf & " Example: Myserver/DC=test,DC=lab ")

cm.CommandText = "<LDAP://" & strDomainDN & ">;(&(objectCategory=user)(proxyAddresses=*));distinguishedName,mail,proxyAddresses;subtree"
cm.Properties("Page Size") = 1000

Set rs                  = cm.Execute


While Not rs.EOF

      On Error Resume Next
      strUserDN      = rs.Fields("distinguishedName")
      strMail            = rs.Fields("mail")
      strProxyAddress = rs.Fields("proxyAddresses")

      objLog.Write "dn: " & strUserDN & vbCrLf
      objLog.Write "changetype: modify" & vbCrLf
      objLog.Write "replace: mail" & vbCrLf
      objLog.Write "mail: " & strMail & vbCrLf
      objLog.Write "-" & vbCrLf & vbCrLf

      objLog.Write "dn: " & strUserDN & vbCrLf
      objLog.Write "changetype: modify" & vbCrLf
      objLog.Write "replace: proxyAddresses" & vbCrLf

      For Each Item in strProxyAddress
            strTempAddr = Item
            objLog.Write "proxyAddresses: " & Item & vbCrLf
      Next

      objLog.Write "-" & vbCrLf & vbCrLf

      rs.MoveNext
Wend
                  

objLog.Close
msgbox "Export Complete to c:\proxydump.ldf"
0
 
LVL 21

Accepted Solution

by:
marc_nivens earned 2000 total points
ID: 11719552
I just noticed that you have a specific way you want the output formatted.  You can modify the above script to do this.  Use the script below if you want it outputted to CSV, user DN in 1st column and proxy addresses in second column (separated by semicolon):




Const Writable      = 2

Set objFSO           = CreateObject("Scripting.FileSystemObject")
Set objLog          = objFSO.OpenTextFile("c:\proxydump.csv", Writable, True)
Set cn               = CreateObject("ADODB.Connection")
Set cm               = CreateObject("ADODB.Command")
Set rs               = CreateObject("ADODB.RecordSet")


With cn
     .Provider     = "ADsDSOObject"
     .Open "Active Directory Provider"
End With

Set cm.ActiveConnection = cn

strDomainDN          = InputBox("Please Enter the Servername and Domain DN. " & vbCrLf & " Example: Myserver/DC=test,DC=lab ")

cm.CommandText = "<LDAP://" & strDomainDN & ">;(&(objectCategory=user)(proxyAddresses=*));distinguishedName,mail,proxyAddresses;subtree"
cm.Properties("Page Size") = 1000

Set rs               = cm.Execute


While Not rs.EOF

     On Error Resume Next
     strUserDN     = rs.Fields("distinguishedName")
     strProxyAddress = rs.Fields("proxyAddresses")

     objLog.Write strUserDN
     objLog.Write ","
 
     For Each Item in strProxyAddress
          strTempAddr = Item
          objLog.Write Item & ";"
     Next

     objLog.Write vbCrLf

     rs.MoveNext
Wend
               

objLog.Close
msgbox "Export Complete to c:\proxydump.csv"
0
 
LVL 8

Author Comment

by:xxgenius
ID: 11719560
thanks, but i will not be able to use a third party too or VB script for security purposes.
0
 
LVL 8

Author Comment

by:xxgenius
ID: 11719621
even though i can't use it for this client, i'm sure i'll be able to use it in the future. thanks.  for this project i'm using some nifty find and replace tricks that worked in a few minutes.
0
 
LVL 17

Expert Comment

by:Microtech
ID: 11719707
that is what i was looking for too thanks ^_^
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
New style of hardware planning for Microsoft Exchange server.
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Suggested Courses

764 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