Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

Am writing a vb.net code where I want to retrieve the email address associated with a Distribution list (not the email addresses mapped in the DL).

For example, if there is a DL named ABC-Support and its associated mail id is ABC-Support@example.com. In my application when a user types the name "ABC-Support" in the text box, it should retrieve the mail address "ABC-Support@example.com"

Am able to do the search for any username, but while trying for DL name it is not working. Maybe am missing something simple. Can someone please help me with this?

VB
deActiveDirectoryEntry = New DirectoryEntry("GC://RootDSE")
            dsAuthenticateDirectorEntry = New DirectoryEntry(String.Concat("GC://", deActiveDirectoryEntry.Properties("rootDomainNamingContext").Value.ToString()))
            dsSearchDir = New DirectorySearcher(dsAuthenticateDirectorEntry)
            dsSearchDir.Filter = "(&(objectClass=user)(|(displayName=" + strPRID + ") (distinguishedName=" + strPRID + ")))"
            dsSearchDir.PropertiesToLoad.Add("mail")
            srResultValue = dsSearchDir.FindOne()

            usermail = srResultValue.Properties("mail")(0)
Posted
Updated 6-Jan-15 4:01am
v2

1 solution

Hi
If you look at your query, you filter it and only receive users
C++
dsSearchDir.Filter = "(&(objectClass=user)(|(displayName=" + strPRID + ") 

It might be
C++
(objectClass=User)(objectClass=Group)
for also reading groups (DLs)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900