Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 14th, 2006, 09:29 AM
Registered User
 
Join Date: Aug 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Zeus_Man Send a message via MSN to Zeus_Man
Default Email from Active Directory

I was wondering if anyone knew how to retrieve a user's email address from Active Directory or Exchange using .NET?

 
Old September 14th, 2006, 10:34 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

As Holmes said to Watson: "Thats elementary".

You will need to import the System.DirectoryServices namespace and do something like this:

        Dim oRoot As DirectoryEntry = New DirectoryEntry([Your LDAP info])
        Dim oSearcher As DirectorySearcher = New DirectorySearcher(oRoot)
        Dim oResults As SearchResultCollection
        Dim strEmail as string

        For Each oResult In oResults
            strEmail = oResult.GetDirectoryEntry().Properties("mail").Val ue
            'Do something
        Next

There may be a few quarks but this is the summary of it all.

"The one language all programmers understand is profanity."
 
Old January 11th, 2007, 12:00 PM
Registered User
 
Join Date: Jan 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am unable to make this code work.
How do you dim oResult?
I tried dimensioning it as a Searchresult but it doesn't like it.
:) Thanks.
 
Old January 11th, 2007, 12:26 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I declare it as type SearchResult, not sure why it isnt working for you.

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature





Similar Threads
Thread Thread Starter Forum Replies Last Post
Active Directory TCSE305 Windows Server 1 November 22nd, 2006 01:26 AM
About Active Directory apalmero VB How-To 1 April 8th, 2005 04:06 PM
Active Directory - help! bubmachine General .NET 2 August 3rd, 2004 04:45 PM
About Active Directory apalmero VS.NET 2002/2003 1 November 9th, 2003 01:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.