PrincipalCollection.Remove Method
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.
Removes the specified principal from the collection, and returns true
if the specified principal object was a member of the collection, and false
otherwise (in which case no operation is performed).
Remove(ComputerPrincipal) |
Removes the specified ComputerPrincipal object from the collection, and returns |
Remove(GroupPrincipal) |
Removes the specified GroupPrincipal object from the collection, and returns |
Remove(Principal) |
Removes the specified Principal object from the collection, and returns |
Remove(UserPrincipal) |
Removes the specified UserPrincipal object from the collection, and returns |
Remove(PrincipalContext, IdentityType, String) |
Finds the UserPrincipal object specified by the given PrincipalContext and |
As with Add, and Contains there are four overloads to this function, but they all do the same thing. The extra overloads are only implemented to improve usability, so that developers using IntelliSense see overloads that take a UserPrincipal, GroupPrincipal, or ComputerPrincipal object. Calling any one of the User, Group, or Computer overloads is exactly equivalent to calling the Principal overload.
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
Removes the specified ComputerPrincipal object from the collection, and returns true
if the ComputerPrincipal was a member of this PrincipalCollection, and false
otherwise (in which case the method performs no operation).
public:
bool Remove(System::DirectoryServices::AccountManagement::ComputerPrincipal ^ computer);
public bool Remove (System.DirectoryServices.AccountManagement.ComputerPrincipal computer);
[System.Security.SecurityCritical]
public bool Remove (System.DirectoryServices.AccountManagement.ComputerPrincipal computer);
member this.Remove : System.DirectoryServices.AccountManagement.ComputerPrincipal -> bool
[<System.Security.SecurityCritical>]
member this.Remove : System.DirectoryServices.AccountManagement.ComputerPrincipal -> bool
Public Function Remove (computer As ComputerPrincipal) As Boolean
Parameters
- computer
- ComputerPrincipal
A ComputerPrincipal object.
Returns
true
if the ComputerPrincipal was a member of this PrincipalCollection; otherwise, false
.
- Attributes
Remarks
This function can throw the following exceptions:
Exception | Description |
---|---|
InvalidOperationException | This method was called on the Members collection for a domain group, and the domain principal to be removed is a member of the group by virtue of its primaryGroupId attribute. |
Applies to
.NET 9 (package-provided) およびその他のバージョン
製品 | バージョン |
---|---|
.NET | 8 (package-provided), 9 (package-provided) |
.NET Framework | 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
Removes the specified GroupPrincipal object from the collection, and returns true
if the GroupPrincipal was a member of this PrincipalCollection, and false
otherwise (in which case the method performs no operation).
public:
bool Remove(System::DirectoryServices::AccountManagement::GroupPrincipal ^ group);
public bool Remove (System.DirectoryServices.AccountManagement.GroupPrincipal group);
[System.Security.SecurityCritical]
public bool Remove (System.DirectoryServices.AccountManagement.GroupPrincipal group);
member this.Remove : System.DirectoryServices.AccountManagement.GroupPrincipal -> bool
[<System.Security.SecurityCritical>]
member this.Remove : System.DirectoryServices.AccountManagement.GroupPrincipal -> bool
Public Function Remove (group As GroupPrincipal) As Boolean
Parameters
- group
- GroupPrincipal
A GroupPrincipal object.
Returns
true
if the GroupPrincipal was a member of this PrincipalCollection; otherwise, false
.
- Attributes
Remarks
This function can throw the following exceptions:
Exception | Description |
---|---|
InvalidOperationException | This method was called on the Members collection for a domain group, and the domain principal to be removed is a member of the group by virtue of its primaryGroupId attribute. |
Applies to
.NET 9 (package-provided) およびその他のバージョン
製品 | バージョン |
---|---|
.NET | 8 (package-provided), 9 (package-provided) |
.NET Framework | 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
Removes the specified Principal object from the collection, and returns true
if the Principal was a member of this PrincipalCollection, and false
otherwise (in which case the method performs no operation).
public:
virtual bool Remove(System::DirectoryServices::AccountManagement::Principal ^ principal);
public bool Remove (System.DirectoryServices.AccountManagement.Principal principal);
[System.Security.SecurityCritical]
public bool Remove (System.DirectoryServices.AccountManagement.Principal principal);
abstract member Remove : System.DirectoryServices.AccountManagement.Principal -> bool
override this.Remove : System.DirectoryServices.AccountManagement.Principal -> bool
[<System.Security.SecurityCritical>]
abstract member Remove : System.DirectoryServices.AccountManagement.Principal -> bool
override this.Remove : System.DirectoryServices.AccountManagement.Principal -> bool
Public Function Remove (principal As Principal) As Boolean
Parameters
Returns
true
if the Principal was a member of this PrincipalCollection; otherwise, false
.
Implements
- Attributes
Remarks
This function can throw the following exceptions:
Exception | Description |
---|---|
InvalidOperationException | This method was called on the Members collection for a domain group, and the domain principal to be removed is a member of the group by virtue of its primaryGroupId attribute. |
Applies to
.NET 9 (package-provided) およびその他のバージョン
製品 | バージョン |
---|---|
.NET | 8 (package-provided), 9 (package-provided) |
.NET Framework | 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
Removes the specified UserPrincipal object from the collection, and returns true
if the UserPrincipal was a member of this PrincipalCollection, and false
otherwise (in which case the method performs no operation).
public:
bool Remove(System::DirectoryServices::AccountManagement::UserPrincipal ^ user);
public bool Remove (System.DirectoryServices.AccountManagement.UserPrincipal user);
[System.Security.SecurityCritical]
public bool Remove (System.DirectoryServices.AccountManagement.UserPrincipal user);
member this.Remove : System.DirectoryServices.AccountManagement.UserPrincipal -> bool
[<System.Security.SecurityCritical>]
member this.Remove : System.DirectoryServices.AccountManagement.UserPrincipal -> bool
Public Function Remove (user As UserPrincipal) As Boolean
Parameters
- user
- UserPrincipal
A UserPrincipal object.
Returns
true
if the UserPrincipal was a member of this PrincipalCollection; otherwise, false
.
- Attributes
Remarks
This function can throw the following exceptions:
Exception | Description |
---|---|
InvalidOperationException | This method was called on the Members collection for a domain group, and the domain principal to be removed is a member of the group by virtue of its primaryGroupId attribute. |
Applies to
.NET 9 (package-provided) およびその他のバージョン
製品 | バージョン |
---|---|
.NET | 8 (package-provided), 9 (package-provided) |
.NET Framework | 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
Finds the UserPrincipal object specified by the given PrincipalContext and identityType
/identityValue
pair from the collection, and returns true
if the identified Principal was a member of this PrincipalCollection, and false
otherwise (in which case the method performs no operation).
public:
bool Remove(System::DirectoryServices::AccountManagement::PrincipalContext ^ context, System::DirectoryServices::AccountManagement::IdentityType identityType, System::String ^ identityValue);
public bool Remove (System.DirectoryServices.AccountManagement.PrincipalContext context, System.DirectoryServices.AccountManagement.IdentityType identityType, string identityValue);
[System.Security.SecurityCritical]
public bool Remove (System.DirectoryServices.AccountManagement.PrincipalContext context, System.DirectoryServices.AccountManagement.IdentityType identityType, string identityValue);
member this.Remove : System.DirectoryServices.AccountManagement.PrincipalContext * System.DirectoryServices.AccountManagement.IdentityType * string -> bool
[<System.Security.SecurityCritical>]
member this.Remove : System.DirectoryServices.AccountManagement.PrincipalContext * System.DirectoryServices.AccountManagement.IdentityType * string -> bool
Public Function Remove (context As PrincipalContext, identityType As IdentityType, identityValue As String) As Boolean
Parameters
- context
- PrincipalContext
A PrincipalContext object.
- identityType
- IdentityType
An IdentityType that identifies the format of identityValue
.
- identityValue
- String
A string.
Returns
true
if the identified Principal was a member of this PrincipalCollection; otherwise, false
.
- Attributes
Remarks
This function can throw the following exceptions:
Exception | Description |
---|---|
InvalidOperationException | This method was called on the Members collection for a domain group, and the domain principal to be removed is a member of the group by virtue of its primaryGroupId attribute. |
NoMatchingPrincipalException | No principal matching the specified parameters was found. |
MultipleMatchesException | More than one principal matches the specified parameters. In theory, this should never happen, because Add throws an exception when there is an attempt to add duplicate principals to the collection. However, it is possible that another API created the duplicate. |
ArgumentException | identityType is an empty string. |
Applies to
.NET 9 (package-provided) およびその他のバージョン
製品 | バージョン |
---|---|
.NET | 8 (package-provided), 9 (package-provided) |
.NET Framework | 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。