Re: List all email addresses in AD
- From: Villain <jdsauer@[not.giving.you]>
- Date: Fri, 26 May 2006 08:39:23 -0700
On Thu, 25 May 2006 15:01:24 -0700, Villain <jdsauer@[not.giving.you]>
wrote:
Hello,~snip~
~snip~
Anyways.. I was wondering if anyone knew of a script that would give
me the following information:
username
email_address_1
email_address_2
etc.
username
email_address_1
Thanks again,
Villain
Here is the code that I found, is there something that would cause the
problem? Is there a change that I should make to it?
Option Explicit
Dim strFilePath, strLdapPath, objFSO, objFile, objConnection, objChild
' Check all arguments required have been passed
If Wscript.Arguments.Count < 2 Then
Wscript.Echo "Arguments <Root DN> <FileName> required. For example:" &
vbCrLf _
& "cscript listuserswithemail.vbs ou=test,dc=demo,dc=test
c:\temp\UserList.txt"
Wscript.Quit(0)
End If
strLdapPath = Wscript.Arguments(0)
strFilePath = Wscript.Arguments(1)
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Open the file for write access.
On Error Resume Next
Set objFile = objFSO.OpenTextFile(strFilePath, 2, True, 0)
If Err.Number <> 0 Then
On Error GoTo 0
Wscript.Echo "File " & strFilePath & " cannot be opened"
Wscript.Quit(1)
End If
On Error GoTo 0
Set objConnection = GetObject("LDAP://" & strLdapPath)
objConnection.Filter = Array("user")
For Each objChild In objConnection
WScript.Echo objChild.Name & vbTab & objChild.givenName & " " &
objChild.sn & " " & objChild.mail
objFile.WriteLine objChild.givenName & "|" & objChild.sn & "|" &
objChild.mail
Next
' Close file connection
objFile.Close
Wscript.Echo "Operation Completed"
.
- References:
- List all email addresses in AD
- From: Villain
- List all email addresses in AD
- Prev by Date: Re: Enumerate local Administrators
- Next by Date: Re: How to update an iframe tag using vbscript? (Permission Denied
- Previous by thread: List all email addresses in AD
- Next by thread: more recent file with power shell
- Index(es):
Relevant Pages
|