Thanks. I just figured it out a couple of minutes ago. This
works:
Set objContainer = GetObject("LDAP://" +
DomainName)
objContainer.Filter =
Array("User")
i = 0
i = 0
For Each objUser In
objContainer
name = objUser.name
wscript.echo "name: " & name & " upn: " & objUser.UserPrincipalName & " sam: " & objUser.samAccountName
name = Right(name, Len(name) - 3)
Set objMailbox = objUser
If objMailbox.HomeMDB = "" Then
'Wscript.echo name + " (no mailbox)"
Else
'Wscript.echo name + " (has mailbox)"
'Wscript.echo objMailbox.HomeMDB
' email addresses
Set objR = objUser
AddressList = objR.ProxyAddresses
for each Address in AddressList
if lcase (left (Address, 5)) = "smtp:" Then
Wscript.echo Address
end if
next
End If
i = i + 1
Next
name = objUser.name
wscript.echo "name: " & name & " upn: " & objUser.UserPrincipalName & " sam: " & objUser.samAccountName
name = Right(name, Len(name) - 3)
Set objMailbox = objUser
If objMailbox.HomeMDB = "" Then
'Wscript.echo name + " (no mailbox)"
Else
'Wscript.echo name + " (has mailbox)"
'Wscript.echo objMailbox.HomeMDB
' email addresses
Set objR = objUser
AddressList = objR.ProxyAddresses
for each Address in AddressList
if lcase (left (Address, 5)) = "smtp:" Then
Wscript.echo Address
end if
next
End If
i = i + 1
Next
'Wscript.echo "Number of users found in " &
DomainName & ": " & i
-----Original Message-----
From: Roger Seielstad [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 11, 2003 5:03 PM
To: '[EMAIL PROTECTED]'
Subject: RE: [ActiveDir] Looking up all email addressesI wrote the code below a while ago to do something similar, and should work for you.Its written for an Exchange 5.5 server, but the logic is pretty similar for AD/E2k as well.--------------------------------------------------------------
Roger D. Seielstad - MTS MCSE MS-MVP
Sr. Systems Administrator
Inovis Inc.-----Original Message-----
From: Michael B. Smith [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 11, 2003 3:51 PM
To: [EMAIL PROTECTED]
Subject: [ActiveDir] Looking up all email addressesI need a piece of code that, given a user object, returns me an object or collection to all of the email addresses for that user. I can't find the object.Help!Set objContainer = GetObject("LDAP://CN=Users," + DomainName)objContainer.Filter = Array("User")
i = 0For Each objUser In objContainer
name = objUser.name
name = Right(name, Len(name) - 3)
Set objMailbox = objUser
<<---->>> code goes here!!!If objMailbox.HomeMDB = "" Then
Wscript.echo name + " (no mailbox)"
Else
Wscript.echo name + " (has mailbox)"
End If
i = i + 1
Next
Wscript.echo "Number of users found in the DS (in the default container): " & iThanks
