It just means that the field isn't populated in Active Directory, I wish they were returning Null or blank string instead. You can try the following code, it works on my laptop. Notice that I use "On Error Resume Next" and then I populate emailid with "
" before trying to assign EmailAddress. Also, you're not gonna get any values for EmailAddress if you don't connect to a domain controller, you can't set that property for local users.
Dim Container As IADsContainer
Dim Child As IADs
Dim othuser As IADsUser
Dim emailid As String
Set Container = GetObject("WinNT://c2/ltrehak")
Container.Filter = Array("user")
On Error Resume Next
For Each Child In Container
emailid = ""
emailid = Child.EmailAddress
Debug.Print Child.Name & ": " & emailid
DoEvents
Next Child
Roman
>Dear All,
>I have written the code to get EmailAddress from Active directory. But it says 'Active directory property cannot be found in the cache'. Can anyone tell me what could be the problem? I would be very thankful. My code is:
>Dim Container As IADsContainer
>Dim Child As IADs
>Dim othuser As IADsUser
>Dim emailid As String
>Set Container = GetObject("WinNT://MUSTAFASULTAN")
>
>Container.Filter = Array("user")
>For Each Child In Container
>Set othuser = GetObject("WinNT://MUSTAFASULTAN" & "/" & Child.Name & ",user")
>emailid = othuser.EmailAddress 'Here is the problem
>Debug.Print emailid
>Next Child
>Thanks and regards,
>Suvi Joseph
Roman Rehak, MCSD, MCDBA, MCSA
Competitive Computing
354 Mountain View Drive
Colchester, VT 05446-5824
802-764-1729