2015-01-16 6 views
0

VB에서 GroupPrincipal을 사용하여 Active Directory 그룹을 만들고 사용자 (및 필요에 따라 다른 그룹)로 채우는 프로그램을 작성했습니다.VB.net에서 AD 그룹 활성화

아무도 나에게 이러한 프로그램을 통해 exchange2010 서버에서 메일 사용이 가능한 그룹을 가져올 수있는 방법을 알려 줄 수 있습니까?

나는 (내 googleing에서) 서버 자체에서 실행할 수있는 몇 가지 파워 쉘을 보았지만 내 그룹이 생성 될 때 자동으로이 그룹을 활성화해야한다.

누군가가 나를 바른 길로 인도 할 수 있다고 생각합니다. 피트.

답변

1

개인 서브 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 = "[email protected]" 

    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:[email protected]" 

    entry.Properties("proxyAddresses").Value = New Object() {"SMTP:[email protected]"} 

    ' 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 
+0

답변을 게시하는 동안, 당신은 또한 당신의 코드가 문제를 해결하는 방법을 설명한다 – AADProgramming