Go Back   Talk Root - PC Hardware, Software and Web Development forums > Internet & Website Management > Programming Discussion > Visual Basic



Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
  #1  
Old 09-12-2004, 12:42 PM
Björn Holmgren
Guest
 
Posts: n/a
Default Re: Help! Can't Get User's Email Address Form Active Directory

As Bob pointed out, the WinNT provider doesn't have a EmailAddress
property for user objects. If you want to retrieve users from AD,
you should bind to the container using LDAP. Example:

Set UserContainer = GetObject("LDAP://ou=users,dc=mydomain,dc=net")

Call UserContainer.GetInfo
UserContainer.Filter = Array("user")
For Each MyUser In UserContainer
MsgBox MyUser.mailAddress
Next

This will enumerate users in the "users" OU of mydomain.net.

Also, may I recommend a great resource called the Technet Script Center:
[url]http://www.microsoft.com/technet/community/scriptcenter/default.mspx[/url]
(look in the repository under "Users and Groups")

It's all VBScript code, but that can easily be converted to "true" VB.

--
Björn Holmgren


"Chris Jones" <ChrisJones@discussions.microsoft.com> wrote in message
news:CBF6E486-E2F6-4B0F-BB4B-663AB2123441@microsoft.com...
> Sorry if this is OT, but I'm not sure where to post an Active Directory
> question.
> In VB 6, When I call AD for a list of users, and iterate through the
> list, I can view the user's name, but little else. If I try to read their
> EmailAddress (for example) I get a runtime error saying "The Directory
> Property Cannot be Found in the Cache."
> What am I doing wrong?
>
> Here's my code:
> Public Sub UserInfo(LoginName As String, result As String)
> Dim UserContainer As IADsContainer
> Dim MyUser As IADsUser
> Dim MyObj As IADsContainer
>
> Set UserContainer = GetObject("WinNT://Progressivex")
>
> Call UserContainer.GetInfo
> UserContainer.Filter = Array("user")
> For Each MyUser In UserContainer
> MsgBox (MyUser.EmailAddress)
> Next MyUser
> End Sub



Reply With Quote
Reply

Bookmarks
Sponsored Links
FatCow $88 Plan for $66 only Host Unlimited Domains on 1 Account Professional Hosting from Just Host


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On



All times are GMT -7. The time now is 10:46 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0
© 2008 TalkRoot.com