GroupPrincipal.Members Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a collection of principal objects that represent the members of the group.
public:
property System::DirectoryServices::AccountManagement::PrincipalCollection ^ Members { System::DirectoryServices::AccountManagement::PrincipalCollection ^ get(); };
public System.DirectoryServices.AccountManagement.PrincipalCollection Members { get; }
member this.Members : System.DirectoryServices.AccountManagement.PrincipalCollection
Public ReadOnly Property Members As PrincipalCollection
Property Value
A PrincipalCollection object that contains the principal objects that represent the members of the group.
Examples
The following code connects to the LDAP domain "fabrikam.com" with the username set to "administrator" and the password set to "SecretPwd123" in the PrincipalContext constructor.
A search is performed to find the group that has name "Domain Admins" under the container specified in the PrincipalContext constructor, "DC=fabrikam,DC=com." If the group is found, the user who has name "John Smith" is removed from the group and the user who has name "Jim Daly" is added to the group
PrincipalContext ctx = new PrincipalContext(ContextType.Domain,
"fabrikam.com",
"DC=fabrikam,DC=com",
"administrator",
"SecretPwd123");
GroupPrincipal grp = GroupPrincipal.FindByIdentity(ctx,
IdentityType.Name,
"Domain Admins");
if (grp != null)
{
grp.Members.Remove(ctx, IdentityType.Name, "John Smith");
grp.Members.Add(ctx, IdentityType.Name, "Jim Daly");
grp.Save();
grp.Dispose();
}
ctx.Dispose();
Remarks
For AD DS groups, the Members property includes user principals that are members of the group because of their primaryId Attribute. When the group contains these types of members, the following restrictions apply:
The Remove method cannot be used to remove members that are part of the group because of their primaryId Attribute.
The Clear method cannot be used to clear members that are part of the group because of their primaryId Attribute.
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기