다음을 통해 공유


그룹 만들기

이 항목에서는 여러 형식의 그룹을 만드는 방법에 대해 자세히 설명합니다.

새 그룹을 만들 때 ADS_GROUP_TYPE_ENUM 열거의 플래그를 사용하여 전역 그룹(ADS_GROUP_TYPE_GLOBAL_GROUP), 도메인 로컬 그룹(ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP), 로컬 그룹(ADS_GROUP_TYPE_LOCAL_GROUP), 유니버설 그룹(ADS_GROUP_TYPE_UNIVERSAL_GROUP) 또는 보안된 그룹(ADS_GROUP_TYPE_SECURITY_ENABLED)과 같은 그룹 형식을 그룹에 할당할 수 있습니다. 그룹 형식을 지정하지 않은 경우 기본적으로 보안된 전역 그룹(ActiveDs.ADS_GROUP_TYPE_ENUM.ADS_GROUP_TYPE_GLOBAL_GROUP | ActiveDs.ADS_GROUP_TYPE_ENUM.ADS_GROUP_TYPE_SECURITY_ENABLED)을 만듭니다. ADS_GROUP_TYPE_ENUM 열거에 대한 자세한 내용은 MSDN Library(https://go.microsoft.com/fwlink/?LinkID=27252)의 "ADS_GROUP_TYPE_ENUM"을 참조하십시오.

다음 Visual Basic .NET 코드 예제에서는 Consulting이라는 조직 구성 단위에 Practice Managers라는 새 그룹을 만드는 방법을 보여 줍니다. 도메인에서 sAMAccountName 특성은 필수적이지만 Windows Server 2003 이상의 도메인에서 sAMAccountName 특성은 선택적입니다. sAMAccountName 특성에 대한 자세한 내용은 MSDN Library(https://go.microsoft.com/fwlink/?LinkID=27252)에서 "sAMAccountName" 또는 "SAM-Account-Name 특성"을 참조하십시오.

' Bind to the domain that this user is currently connected to.
Dim dom As New DirectoryEntry()

' Find the container (in this case, the Consulting organizational unit) that you 
' wish to add the new group to.
Dim ou As DirectoryEntry = dom.Children.Find("OU=Consulting")

' Add the new group Practice Managers.
Dim group As DirectoryEntry = ou.Children.Add("CN=Practice Managers", "group")

' Set the samAccountName for the new group.
group.Properties("samAccountName").Value = "pracmans"

' Commit the new group to the directory.
group.CommitChanges()

다음 C# 코드 예제에서는 Consulting이라는 조직 구성 단위에 Practice Managers라는 새 그룹을 만드는 방법을 보여 줍니다. 도메인에서 sAMAccountName 특성은 필수적이지만 Windows Server 2003 이상의 도메인에서 sAMAccountName 특성은 선택적입니다. sAMAccountName 특성에 대한 자세한 내용은 MSDN Library(https://go.microsoft.com/fwlink/?LinkID=27252)에서 "sAMAccountName" 또는 "SAM-Account-Name 특성"을 참조하십시오.

// Bind to the domain that this user is currently connected to.
DirectoryEntry dom = new DirectoryEntry();

// Find the container (in this case, the Consulting organizational unit) that you 
// wish to add the new group to.
DirectoryEntry ou = dom.Children.Find("OU=Consulting");

// Add the new group Practice Managers.
DirectoryEntry group = ou.Children.Add("CN=Practice Managers", "group");

// Set the samAccountName for the new group.
group.Properties["samAccountName"].Value = "pracmans";

// Commit the new group to the directory.
group.CommitChanges();

다음 Visual Basic .NET 코드 예제에서는 Consulting 조직 구성 단위에 Managers라는 로컬 도메인 그룹을 만드는 방법을 보여 줍니다. ADSI 액세스에 COM Interop 사용를 사용하여 ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP 플래그를 지정합니다.

' Bind to the domain that this user is currently connected to.
Dim dom As New DirectoryEntry()

' Find the container (in this case, the Consulting organizational unit) that you 
' wish to add the new local domain group to.
Dim ou As DirectoryEntry = dom.Children.Find("OU=Consulting")

' Add the Managers group.
Dim mgr As DirectoryEntry = ou.Children.Add("CN=Managers", "group")

' Set the group type to a secured domain local group.
mgr.Properties("groupType").Value = ActiveDs.ADS_GROUP_TYPE_ENUM.ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP Or ActiveDs.ADS_GROUP_TYPE_ENUM.ADS_GROUP_TYPE_SECURITY_ENABLED

' Commit the new group to the directory.
mgr.CommitChanges()

다음 C# 코드 예제에서는 Consulting 조직 구성 단위에 Managers라는 로컬 도메인 그룹을 만드는 방법을 보여 줍니다. ADSI 액세스에 COM Interop 사용를 사용하여 ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP 플래그를 지정합니다.

// Bind to the domain that this user is currently connected to.
DirectoryEntry dom = new DirectoryEntry();

// Find the container (in this case, the Consulting organizational unit) that you 
// wish to add the new local domain group to.
DirectoryEntry ou = dom.Children.Find("OU=Consulting");

// Add the Managers group.
DirectoryEntry mgr = ou.Children.Add("CN=Managers", "group");

// Set the group type to a secured domain local group.
mgr.Properties["groupType"].Value = ActiveDs.ADS_GROUP_TYPE_ENUM.ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP | 
ActiveDs.ADS_GROUP_TYPE_ENUM.ADS_GROUP_TYPE_SECURITY_ENABLED;

// Commit the new group to the directory.
mgr.CommitChanges();

다음 Visual Basic .NET 코드 예제에서는 Consulting 조직 구성 단위에 Full Time Employees라는 배포 목록인 비보안 그룹을 만드는 방법을 보여 줍니다. ADSI 액세스에 COM Interop 사용를 사용하여 ADS_GROUP_TYPE_GLOBAL_GROUP 플래그를 지정합니다.

' Bind to the domain that this user is currently connected to.
Dim dom As New DirectoryEntry()

' Find the container (in this case, the Consulting organizational unit) that you
' wish to add the Full Time Employees distribution list to.
Dim ou As DirectoryEntry = dom.Children.Find("OU=Consulting")

' Add the Full Time Employees distribution list.
Dim dl As DirectoryEntry = ou.Children.Add("CN=Full Time Employees", "group")

' Set the group type to global.
dl.Properties("groupType").Value = ActiveDs.ADS_GROUP_TYPE_ENUM.ADS_GROUP_TYPE_GLOBAL_GROUP

' Commit the new group to the directory.
dl.CommitChanges()

다음 C# 코드 예제에서는 Consulting 조직 구성 단위에 Full Time Employees라는 배포 목록인 비보안 그룹을 만드는 방법을 보여 줍니다. ADSI 액세스에 COM Interop 사용를 사용하여 ADS_GROUP_TYPE_GLOBAL_GROUP 플래그를 지정합니다.

// Bind to the domain that this user is currently connected to.
DirectoryEntry dom = new DirectoryEntry();

// Find the container (in this case, the Consulting organizational unit) that you
// wish to add the Full Time Employees distribution list to.
DirectoryEntry ou = dom.Children.Find("OU=Consulting");

// Add the Full Time Employees distribution list.
DirectoryEntry dl = ou.Children.Add("CN=Full Time Employees", "group");

// Set the group type to global.
dl.Properties["groupType"].Value = ActiveDs.ADS_GROUP_TYPE_ENUM.ADS_GROUP_TYPE_GLOBAL_GROUP;

// Commit the new group to the directory.
dl.CommitChanges();

다음 Visual Basic .NET 코드 예제에서는 전체 그룹을 다른 그룹에 추가하는 방법을 보여 줍니다.

' Bind to the domain that this user is currently connected to.
Dim dom As New DirectoryEntry()

' Find the container (in this case, the North America group) that you
' wish to add.
Dim group As DirectoryEntry = dom.Children.Find("CN=North America")

' Connect to the group that you wish to add "group" to.
Dim mgr As New DirectoryEntry("LDAP://CN=Managers,OU=Consulting,DC=Fabrikam,DC=COM")

' Add the distinguishedName of "group" to the members property of "mgr".
mgr.Properties("member").Add(group.Properties("distinguishedName").Value)

' Commit the changes to the directory.
mgr.CommitChanges()

다음 C# 코드 예제에서는 전체 그룹을 다른 그룹에 추가하는 방법을 보여 줍니다.

// Bind to the domain that this user is currently connected to.
DirectoryEntry dom = new DirectoryEntry();

// Find the container (in this case, the North America group) that you
// wish to add.
DirectoryEntry group = dom.Children.Find("CN=North America");

// Connect to the group that you wish to add "group" to.
DirectoryEntry mgr = new DirectoryEntry("LDAP://CN=Managers,OU=Consulting,DC=Fabrikam,DC=COM");

// Add the distinguishedName of "group" to the members property of "mgr".
mgr.Properties["member"].Add(group.Properties["distinguishedName"].Value);

// Commit the changes to the directory.
mgr.CommitChanges();

참고 항목

참조

System.DirectoryServices

개념

그룹 관리
ADSI 액세스에 COM Interop 사용

Send comments about this topic to Microsoft.

Copyright © 2007 by Microsoft Corporation. All rights reserved.