Retriving User Details from Active Directory in VB using ADODB

  • Thread starter Thread starter Kuntesh Desai
  • Start date Start date
K

Kuntesh Desai

Hi!

I am trying to retrieve user details from a Windows 2000 Active Directory using ADO and am successful to retrieve all info except the Postal address... I get the following error when I try to use "PostalAddresses" property of an "IADsUser" object.

Following is the code that I have used...

Dim User As IADsUser

Set User = GetObject(rs("adspath"))
'rs is a recordset object containing AD info.

UserFName = User.FirstName
UserLName = User.LastName
UserDepartmentName = User.Department
UserTelePhoneNo = User.TelephoneNumber
'Alls well till this point...
UserAddress = User.PostalAddresses()
Here is where I get following error :-
Number :- -2147463155
Description :- "The Active Directory property cannot be found in the cache."

Would appreciate if someone points out what the problem on hand is and suggest a workaround for the same.

Thanks in advance,
Kuntesh Desai
 
¤ Hi!
¤
¤ I am trying to retrieve user details from a Windows 2000 Active Directory using ADO and am successful to retrieve all info except the Postal address... I get the following error when I try to use "PostalAddresses" property of an "IADsUser" object.
¤
¤ Following is the code that I have used...
¤
¤ Dim User As IADsUser
¤
¤ Set User = GetObject(rs("adspath"))
¤ 'rs is a recordset object containing AD info.
¤
¤ UserFName = User.FirstName
¤ UserLName = User.LastName
¤ UserDepartmentName = User.Department
¤ UserTelePhoneNo = User.TelephoneNumber
¤ 'Alls well till this point...
¤ UserAddress = User.PostalAddresses()
¤ Here is where I get following error :-
¤ Number :- -2147463155
¤ Description :- "The Active Directory property cannot be found in the cache."
¤
¤ Would appreciate if someone points out what the problem on hand is and suggest a workaround for the same.

The PostalAddress property is an array of Variants. You probably need to define UserAddress as an
Object and call GetEx to return the array of address lines.

UserAddress = User.GetEx("PostalAddress")


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Paul,

I tried using your suggestion, however I still get the same error.

Thanks for the efforts though.
Kuntesh Desai

Paul Clement said:
¤ Hi!
¤
¤ I am trying to retrieve user details from a Windows 2000 Active
Directory using ADO and am successful to retrieve all info except the Postal
address... I get the following error when I try to use "PostalAddresses"
property of an "IADsUser" object.
¤
¤ Following is the code that I have used...
¤
¤ Dim User As IADsUser
¤
¤ Set User = GetObject(rs("adspath"))
¤ 'rs is a recordset object containing AD info.
¤
¤ UserFName = User.FirstName
¤ UserLName = User.LastName
¤ UserDepartmentName = User.Department
¤ UserTelePhoneNo = User.TelephoneNumber
¤ 'Alls well till this point...
¤ UserAddress = User.PostalAddresses()
¤ Here is where I get following error :-
¤ Number :- -2147463155
¤ Description :- "The Active Directory property cannot be found in the cache."
¤
¤ Would appreciate if someone points out what the problem on hand is and
suggest a workaround for the same.
 
¤ Paul,
¤
¤ I tried using your suggestion, however I still get the same error.
¤
¤ Thanks for the efforts though.
¤ Kuntesh Desai

Well I looked at your code but not the error you were receiving. Was the PostalAddress property
originally added to the AD User record? If it wasn't then the actual *property* will not be stored.
PostalAddress is an extended property of the IADUser object.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top