Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need some assistance please...

Status
Not open for further replies.

lewatkin

Programmer
Mar 8, 2002
91
US
Can someone explain to me why the following code will only return the user name in the domain?

Function ListUsers()
Dim MyDomain As Object
Dim user As IADsUser

Set MyDomain = GetObject("WinNT://" & Environ("USERDOMAIN"))

MyDomain.Filter = Array("user")

For Each user In MyDomain
MsgBox "User Name:" & user.Name
MsgBox "User Desc:" & user.Title
MsgBox "User TelNo:" & user.Department
Next


End Function


The code will provide the user name, but will give me:

Run-time error '-2147463155 = The directory property cannot be found in the cache.

I am stumped. Using Access 2003 on a Windows network with Active Directory.

Any help would be awesome!!

Lee
 
You will get that error if one of the fields that you are trying to access is not defined for the AD object that you are looking at. So check to make sure that Name, Title, and Department are defined for every AD record that the query will produce.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Thank you for replying, but I am not sure I understand what you mean 'defined'. They are fields in the AD, and I can get to them and see them in VBA using the shorcuts. Sorry to be a pain, I just don't know what you mean?
 
I can get to them and see them in VBA using the shorcuts."

What shortcuts? Regardless, that error is telling you that for some AD record you are trying to access a field that does not exist.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top