Making list of e-mail addresses

  • From: "John Tolmachoff \(Lists\)" <johnlist@xxxxxxxxxxxxxxxxxxx>
  • To: "'[ExchangeList]'" <exchangelist@xxxxxxxxxxxxx>
  • Date: Thu, 24 Jun 2004 11:24:55 -0700

I am trying to make a list of users e-mail addresses.

I followed the article

And I ended up with this file:
Dim rootDSE, domainObject
Set rootDSE=GetObject("LDAP://RootDSE";)
DomainContainer = rootDSE.Get("defaultNamingContext")
Set fs = CreateObject ("Scripting.FileSystemObject")
Set userFile = fs.CreateTextFile ("c:\users.csv")

Set conn = CreateObject("ADODB.Connection")
conn.Provider = "ADSDSOObject"
conn.Open "ADs Provider"

ldapStr = "<LDAP://"; & DomainContainer & ">;(&(&(& (mailnickname=*) (|
p/ou=First Administrative Group/cn=Configuration/cn=Servers/cn=SRV3)) ))))"

Set rs = conn.Execute(ldapStr)

While Not rs.EOF
Set oUser = GetObject (rs.Fields(0).Value)
userFile.Write oUser.displayName & "," & _
   oUser.sAMAccountName & "," & oUser.userprincipalname & ","
      for each email in oUser.proxyAddresses
            userFile.Write email & ","
       userFile.WriteLine ""

However, when I run it, it keep getting a Windows Scripting Host error:
Script:         C:\users.vbs
Line:           13
Char:           1
Error:          One or more errors occurred during processing of command
Code:           80040E14
Source: Provider

Can some one explain what the error is and how to fix?

John Tolmachoff
eServices For You

Other related posts: