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)

Re: VB6 "unspecified automation error -2147467259 " by Richard

Richard
Tue May 08 21:00:15 CDT 2007


<caveman182@msn.com> wrote in message
news:1178663122.838181.200070@o5g2000hsb.googlegroups.com...
>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)
>

Assuming you do not want to append to any existing values, this should work:

Dim arrNewAddresses(0)
arrNewAdresses(0) = MyEmail.Address@Company.com
objUser.PutEx ADS_PROPERTY_UPDATE, "proxyAddresses", arrNewAddresses

You specify the entire array, even if there is just one value, in the PutEx
method. If you want to append your new value to any existing, use
ADS_PROPERTY_APPEND. Also, note that an array Dim'ed with dimension 1, as
aryNewAddress(1), will have two elements in the array, indexed by 0 and 1,
which is not what you want. In fact, since null values usually are not
allowed, this may even raise an error, as aryNewAddress(1) will be null.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--



Re: VB6 "unspecified automation error -2147467259 " by caveman182

caveman182
Sat May 19 12:56:03 CDT 2007

On May 8, 9:00 pm, "Richard Mueller [MVP]" <rlmueller-
nos...@ameritech.nospam.net> wrote:
> <caveman...@msn.com> wrote in message
>
> news:1178663122.838181.200070@o5g2000hsb.googlegroups.com...
>
>
>
>
>
> >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.Addr...@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.Addr...@Company.com"
>
> > 2) Attempt 2:
> > strNewAddress="MyEmail.Addr...@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.Addr...@Company.com"
> > Set objUser = GetObject("LDAP://" & strDN)
> > objUser.PutEx ADS_PROPERTY_UPDATE, "proxyAddresses", aryNewAddress(0)
>
> Assuming you do not want to append to any existing values, this should work:
>
> Dim arrNewAddresses(0)
> arrNewAdresses(0) = MyEmail.Addr...@Company.com
> objUser.PutEx ADS_PROPERTY_UPDATE, "proxyAddresses", arrNewAddresses
>
> You specify the entire array, even if there is just one value, in the PutEx
> method. If you want to append your new value to any existing, use
> ADS_PROPERTY_APPEND. Also, note that an array Dim'ed with dimension 1, as
> aryNewAddress(1), will have two elements in the array, indexed by 0 and 1,
> which is not what you want. In fact, since null values usually are not
> allowed, this may even raise an error, as aryNewAddress(1) will be null.
>
> --
> Richard Mueller
> Microsoft MVP Scripting and ADSI
> Hilltop Lab -http://www.rlmueller.net
> --- Hide quoted text -
>
> - Show quoted text -

Sorry, I've been out of town and just returned to see your reply. It
worked perfectly for me. I have to admit that I find myself a bit awed
(hopefully not 'odd') to have gotten a response from you. I have many
times explored your responses, always well considered and useful, to
users' VB questions and view you as a bit of a legend in these
parts! :) Thanks very much for taking the time to assist those of
us who struggle!
NE