Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Extract All SMTP Addresses in Domain

Posted on 2004-08-04
5
Medium Priority
?
3,806 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
In this video we show how to create a Contact 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 Recipients >> Contact ta…
how to add IIS SMTP to handle application/Scanner relays into office 365.
Suggested Courses

609 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