Lösung:
Teil 1 - auslesen samaccountname + legacyExchangeDN
----------------
set fs = CreateObject ("Scripting.FileSystemObject")
datei1 = "legExchDN.txt"
Set userinfo = fs.CreateTextFile (datei1,true)
userinfo.writeline "SamAccountName legacyExchangeDN"
Set root = GetObject ("LDAP://rootDSE")
dom = Inputbox("Domain:","ADSPath",root.Get("defaultNamingContext"))
If dom = "" Then
MsgBox "Script wird auf Benutzerwunsch hin abgebrochen."
Wscript.Quit
else
dom = "<LDAP://" & dom
End If
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = dom & ">;(&(objectCategory=person)(objectClass=user)(legacyExchangeDN=*));ADsPath;subtree"
Set objRecordSet = objCommand.Execute
While Not objRecordset.EOF
strADsPath = objRecordset.Fields("ADsPath")
Set objUser = GetObject(strADsPath)
userinfo.writeline objuser.samaccountname & vbtab & objuser.legacyExchangeDN
objrecordset.MoveNext
set objuser = nothing
Wend
userinfo.close
Set userinfo= Nothing
set fs = Nothing
wscript.echo "Fertig..."
----------------
Teil 2 - setzen der X.500 Adresse für alle Benutzer aus Teil 1
----------------
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("x500.txt", ForReading)
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
arr = Split(strNextLine , chr(9))
SetProxyAddressForUser arr(0),arr(1) 'Parameter: Benutzer, X500-Adresse
Loop
Sub SetProxyAddressForUser(sUser,sAddress)
' WScript.Echo sUser & ";" & sAddress
Set oUser = GetObject ("LDAP://CN=" & sUser & ",OU=domain user,DC=dom1,DC=local")
vProxyAddresses = oUser.ProxyAddresses
nProxyAddresses = UBound(vProxyAddresses)
bFound=False
for i = 0 to nProxyAddresses
If vProxyAddresses(i) = sAddress then
bFound = True
Exit For
End If
next
If not bFound then
Redim Preserve vProxyAddresses(nProxyAddresses + 1)
vProxyAddresses(nProxyAddresses + 1) = sAddress
oUser.ProxyAddresses = vProxyAddresses
oUser.SetInfo
End If
End Sub
wscript.echo "Fertig..."
----------------
ich weiss nicht, ob noch etwas optimiert werden sollte, aber es funktioniert erstmal ;)
Grüße