如何从Active Directory检索与DL关联的电子邮件地址? [英] How do I retrieve e-mail address associated with a DL from Active Directory?
问题描述
您好,
我正在编写一个vb.net代码,我想要检索与分发列表关联的电子邮件地址(而不是DL中映射的电子邮件地址) )。
例如,如果有名为ABC-Support的DL,其关联的邮件ID为ABC-Support@example.com。在我的应用程序中,当用户在文本框中键入名称ABC-Support时,它应该检索邮件地址ABC-Support@example.com
能够搜索任何用户名,但在尝试DL名称时,它无法正常工作。也许我错过了一些简单的事有人可以帮我这个吗?
deActiveDirectoryEntry = 新 DirectoryEntry ( GC:// RootDSE)
dsAuthenticateDirectorEntry = New DirectoryEntry( String .Concat( GC://,deActiveDirectoryEntry.Properties( rootDomainNamingContext)。 Value.ToString()))
dsSearchDir = 新 DirectorySearcher(dsAuthenticateDirectorEntry)
dsSearchDir.Filter = (&(objectClass = user)(|(displayName = + strPRID + )(distinguishedName = + strPRID + )))
dsSearchDir.PropertiesToLoad.Add( mail)
srResultValue = dsSearchDir.FindOne()
usermail = srResultValue.Properties( mail)( 0 )
您好b $ b
如果查看您的查询,您可以过滤它并仅接收用户
dsSearchDir.Filter = (&(objectClass = user)(|(displayName = + strPRID + )
对于读取组(DL)
(objectClass = User)(objectClass = Group)
>
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?
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)
Hi
If you look at your query, you filter it and only receive users
dsSearchDir.Filter = "(&(objectClass=user)(|(displayName=" + strPRID + ")
It might be(objectClass=User)(objectClass=Group)for also reading groups (DLs)
这篇关于如何从Active Directory检索与DL关联的电子邮件地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!