I have snipped the code below out of a Function I use to read and write
proxyAddresses of user and contact class accounts in a 20003 Active
Directory. But, when I recently tried using the same code on a
Distribution Group, I found the code fails on line: "v1 =
cnvt.CStrArray(oRecordset.Fields("proxyaddresses").Value)". However,
the second below where I simply use "objUserCon.PutEx 3,
"proxyaddresses", Array(priAddr)" works fine. Can anyone tell me why?
Can I not use convert on proxyAddresses on groups?
Set objUserCon = GetObject("LDAP://CN=" & UserID & "," & LDAPstring)
If UserExists then
err.clear
v1 = ""
Set cnvt = CreateObject("ADs.ArrayConvert")
Set oConnection = CreateObject("ADODB.Connection")
Set oRecordset = CreateObject("ADODB.Recordset")
oConnection.Provider = "ADsDSOObject"
oConnection.Open "ADs Provider"
strUser = "<LDAP://" & objuserCon.distinguishedName & ">"
strQuery = strUser &
";(objectClass=contact);adspath,proxyaddresses;subtree"
Set oRecordset = oConnection.Execute(strQuery)
v1 = cnvt.CStrArray(oRecordset.Fields("proxyaddresses").Value)
If err.number = 0 then
For Each v2 In v1
If left(v2,5) = "SMTP:" then
If lcase(mid(v2,6)) = lcase(pnum) then
If loopCount >= 1 then
f1.writeline mid(v2,6) & " = " & pnum
End If
Else
If loopCount >= 1 then
f1.writeline mid(v2,6) & " becomes " & pnum
End If
If writeEnabled Then
' delete the old primary proxy address
ObjUserCon.PutEx 4, "proxyAddresses", Array(v2)
ObjUserCon.SetInfo
' write the new primary proxy address
ObjUserCon.PutEx 3, "proxyAddresses", Array("SMTP:" & pnum)
'Update the target address
ObjUserCon.Put "targetAddress", "SMTP:" & pnum
ObjUserCon.SetInfo
elem = phUserID
conMembers
scriptRerun = True
End If
End If
End If
End IF
Next
End If
ElseIf writeEnabled Then
priAddr = "SMTP:" & pnum
objUserCon.Put "mailNickname",phUserID
objUserCon.Put "targetAddress",priAddr
objUserCon.PutEx 3, "proxyaddresses", Array(priAddr)
objUserCon.SetInfo
If loopCount >= 1 then
f1.writeline """" & """" & " becomes " & pnum
End If
End If
Set objUserCon = Nothing
|