繁体   English   中英

如何通过VB.net邮件启用AD组

[英]How to Mail Enable an AD Group with VB.net

我已经在VB中编写了一个程序,该程序使用GroupPrincipal创建Active Directory组,并在其中填充用户(和/或其他必要的组)。

任何人都可以给我指点一下如何通过同一程序在我们的Exchange2010服务器上启用这些组的邮件吗?

我已经看到(在Google搜索中)可以在服务器本身上运行的某些Powershell,但是我需要我的程序在创建这些组时自动启用它们。

希望有人能让我走上正确的道路。 皮特。

私人子CreateDistributionList()

    Dim ad As DirectoryEntry

    Dim contacts As DirectoryEntry

    Dim entry As DirectoryEntry



    ' Create a conntaction to Active Directory

    ad = New DirectoryEntry("LDAP://MACHINENAME/DC=DOMAIN,DC=COM", "username", "password")

    ' Find the OU to create the contact in

    contacts = ad.Children.Find("OU=Distrubtion Lists")



    ' Create AD object

    entry = contacts.Children.Add("CN=LastName\, FirstName", "group")



    ' Fill out basic attributes

    entry.Properties("groupType").Value = 8 ' 8 = Universal Group

    entry.Properties("displayName").Value = "Name"

    entry.Properties("sAMAccountName").Value = "Name" ' I don't know if this is required

    entry.Properties("mail").Value = "EmailAddress@Something.com"

    entry.Properties("telephoneNumber").Value = "555-555-5555"

    entry.Properties("description").Value = "description"



    ' The follow attributes I believe to be the ones required for mail enabling

    ' (though I have not testing thoroughly to pinpoint exactly what is required)



    ' SMPT MUST be capitalized

    entry.Properties("targetAddress").Value = "SMTP:EmailAddress@Something.com"

    entry.Properties("proxyAddresses").Value = New Object() {"SMTP:EmailAddress@Something.com"}

    ' To find the legacyExchangeDN, copy value from an existing contact

    entry.Properties("legacyExchangeDN").Value = ""

    ' mailNickName can not have spaces

    entry.Properties("mailNickName").Value = New String("FirstNameLastName").Replace(" ", "")



    ' Commit Changes to Active Directory

    entry.CommitChanges()



    ' Close connections to Active Directory

    entry.Close()

    ad.Close()

End Sub

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM