Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to get EmailAddress from Active Directory
Message
From
29/03/2003 12:11:20
 
 
To
29/03/2003 02:19:28
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00770628
Message ID:
00771729
Views:
7
This message has been marked as the solution to the initial question of the thread.
As it turns out, the WinNT provider doesn't expose this attibute. It shows as valid in the debugger but you'll never get the value. You'll have to switch to the LDAP provider, that's actually recommended because the WinNT provider is pretty much used just for legacy support and it doesn't include many new features of Active Directory. Here is a sample code for getting emails with the LDAP provider, with this code I do get the Email field from the General tab. You'll have to use LDAP path and navigate down to either a group (cn=users) or an Organizational Unit (OU=Sales).

Dim ADGroup As Object
Dim ADUser As Object
Dim Email As String

On Error GoTo ErrorHandler

Set ADGroup = GetObject("LDAP://cn=users,dc=ddcsoftware,dc=com")

On Error Resume Next
For Each ADUser In ADGroup
If ADUser.Class = "user" Then
Email = ""
Email = ADUser.EmailAddress
Debug.Print ADUser.FullName & ": " & Email
End If
Next

Exit Sub
ErrorHandler:
MsgBox Err.Description



>Hi Roman,
>I tried it. It is not working it gives me blank email id even if it is there in the active Directory. I think the email address should be there when I open Active directory and the Properties of a user, it should be there in the E-mail in General tab right? It is there but it is not picking up. What could be the reason?
>Regards,
>Suvi Joseph
Roman Rehak, MCSD, MCDBA, MCSA
Competitive Computing
354 Mountain View Drive
Colchester, VT 05446-5824
802-764-1729
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform