I have a VB6 app and am trying to update the proxyAddresses (multi-
value) attribute in our Active Directory and am getting the following
error:
'run-time error "-2147467259 (80004005)': Unspecified error
I can set single-value attributes (e.g., "description", "mail") just
fine but not proxyAddresses.
I can't see anything wrong and wonder if someone out there has the
magic touch. The ultimate goal is to ADD or DELETE entries in this
attribute. The preliminary code follows that does work for everything
else, it seems, but this:
Private Sub WriteAttributes()
Dim adoCommand, adoConnection, strBase
Dim objRootDSE, strDNSDomain, strQuery, adoRecordset, aryValues(1)
Dim strName, strCN, colMail, strMail, objUser, strDN,
strNewAddress As String
Const ADS_PROPERTY_CLEAR = 1
Const ADS_PROPERTY_UPDATE = 2
Const ADS_PROPERTY_APPEND = 3
Const ADS_PROPERTY_DELETE = 4
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "<LDAP://" & strDNSDomain & ">"
strFilter = "(&(objectCategory=Person)(objectClass=User)(homeMDB=*))"
strAttributes=
"distinguishedName,cn,sAMAccountName,employeeID,mail,proxyAddresses"
strQuery = strBase & ";" & strFilter & ";" & strAttributes &
";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 10000
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
Set adoRecordset = adoCommand.Execute
Do Until adoRecordset.EOF
colMail = adoRecordset.Fields("proxyAddresses")
For Each strMail In colMail
strDN = adoRecordset.Fields("distinguishedName")
Set objUser = GetObject("LDAP://" & strDN)
objUser.Description="My new description" '(this
works fine)
objUser.mail="MyNewMail.Address@company.com '(this
works fine)
'<<Failing code runs here - see examples below<<
objUser.SetInfo
Next
Loop
End Sub
***
The failing code, which sits right after the objUser.mail attribute
write, looks like this (all the following approaches failed with the
same code):
1) Attempt 1:
Set objUser = GetObject("LDAP://" & strDN)
objUser.PutEx _
ADS_PROPERTY_UPDATE, "proxyAddresses", "MyEmail.Address@Company.com"
2) Attempt 2:
strNewAddress="MyEmail.Address@Company.com"
Set objUser = GetObject("LDAP://" & strDN)
objUser.PutEx ADS_PROPERTY_UPDATE, "proxyAddresses", strNewAddress
3) Attempt3:
strNewAddress="MyEmailAddressCompanycom" 'No special characters.
Set objUser = GetObject("LDAP://" & strDN)
objUser.PutEx ADS_PROPERTY_UPDATE, "proxyAddresses", strNewAddress
4) Attempt 4:
Dim aryNewAddress(1)
aryNewAddress(0)="MyEmail.Address@Company.com"
Set objUser = GetObject("LDAP://" & strDN)
objUser.PutEx ADS_PROPERTY_UPDATE, "proxyAddresses", aryNewAddress(0)