PrincipalCollection.Contains 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.
Returns a value that indicates whether the specified Principal is a member of the PrincipalCollection. The Principal can be specified in the same manner as in the Add methods.
Contains(ComputerPrincipal) |
Returns a value indicating whether the collection contains the specified ComputerPrincipal object. |
Contains(GroupPrincipal) |
Returns a value indicating whether the collection contains the specified GroupPrincipal object. |
Contains(Principal) |
Returns a value indicating whether the collection contains the specified Principal object. |
Contains(UserPrincipal) |
Returns a value indicating whether the collection contains the specified UserPrincipal object. |
Contains(PrincipalContext, IdentityType, String) |
Returns a value indicating whether the Principal object matching the |
As with Add, and Remove 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
Returns a value indicating whether the collection contains the specified ComputerPrincipal object.
public:
bool Contains(System::DirectoryServices::AccountManagement::ComputerPrincipal ^ computer);
public bool Contains (System.DirectoryServices.AccountManagement.ComputerPrincipal computer);
[System.Security.SecurityCritical]
public bool Contains (System.DirectoryServices.AccountManagement.ComputerPrincipal computer);
member this.Contains : System.DirectoryServices.AccountManagement.ComputerPrincipal -> bool
[<System.Security.SecurityCritical>]
member this.Contains : System.DirectoryServices.AccountManagement.ComputerPrincipal -> bool
Public Function Contains (computer As ComputerPrincipal) As Boolean
Parameters
- computer
- ComputerPrincipal
A ComputerPrincipal object.
Returns
true
if the collection contains the specified object; otherwise, false
.
- Attributes
Applies to
.NET 9 (package-provided) and other versions
Product | Versions |
---|---|
.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
Returns a value indicating whether the collection contains the specified GroupPrincipal object.
public:
bool Contains(System::DirectoryServices::AccountManagement::GroupPrincipal ^ group);
public bool Contains (System.DirectoryServices.AccountManagement.GroupPrincipal group);
[System.Security.SecurityCritical]
public bool Contains (System.DirectoryServices.AccountManagement.GroupPrincipal group);
member this.Contains : System.DirectoryServices.AccountManagement.GroupPrincipal -> bool
[<System.Security.SecurityCritical>]
member this.Contains : System.DirectoryServices.AccountManagement.GroupPrincipal -> bool
Public Function Contains (group As GroupPrincipal) As Boolean
Parameters
- group
- GroupPrincipal
A GroupPrincipal object.
Returns
true
if the collection contains the specified object; otherwise, false
.
- Attributes
Applies to
.NET 9 (package-provided) and other versions
Product | Versions |
---|---|
.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
Returns a value indicating whether the collection contains the specified Principal object.
public:
virtual bool Contains(System::DirectoryServices::AccountManagement::Principal ^ principal);
public bool Contains (System.DirectoryServices.AccountManagement.Principal principal);
[System.Security.SecurityCritical]
public bool Contains (System.DirectoryServices.AccountManagement.Principal principal);
abstract member Contains : System.DirectoryServices.AccountManagement.Principal -> bool
override this.Contains : System.DirectoryServices.AccountManagement.Principal -> bool
[<System.Security.SecurityCritical>]
abstract member Contains : System.DirectoryServices.AccountManagement.Principal -> bool
override this.Contains : System.DirectoryServices.AccountManagement.Principal -> bool
Public Function Contains (principal As Principal) As Boolean
Parameters
Returns
true
if the collection contains the specified object; otherwise, false
.
Implements
- Attributes
Applies to
.NET 9 (package-provided) and other versions
Product | Versions |
---|---|
.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
Returns a value indicating whether the collection contains the specified UserPrincipal object.
public:
bool Contains(System::DirectoryServices::AccountManagement::UserPrincipal ^ user);
public bool Contains (System.DirectoryServices.AccountManagement.UserPrincipal user);
[System.Security.SecurityCritical]
public bool Contains (System.DirectoryServices.AccountManagement.UserPrincipal user);
member this.Contains : System.DirectoryServices.AccountManagement.UserPrincipal -> bool
[<System.Security.SecurityCritical>]
member this.Contains : System.DirectoryServices.AccountManagement.UserPrincipal -> bool
Public Function Contains (user As UserPrincipal) As Boolean
Parameters
- user
- UserPrincipal
A UserPrincipal object.
Returns
true
if the collection contains the specified object; otherwise, false
.
- Attributes
Applies to
.NET 9 (package-provided) and other versions
Product | Versions |
---|---|
.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
Returns a value indicating whether the Principal object matching the identityType
/identityValue
pair is in the collection.
public:
bool Contains(System::DirectoryServices::AccountManagement::PrincipalContext ^ context, System::DirectoryServices::AccountManagement::IdentityType identityType, System::String ^ identityValue);
public bool Contains (System.DirectoryServices.AccountManagement.PrincipalContext context, System.DirectoryServices.AccountManagement.IdentityType identityType, string identityValue);
[System.Security.SecurityCritical]
public bool Contains (System.DirectoryServices.AccountManagement.PrincipalContext context, System.DirectoryServices.AccountManagement.IdentityType identityType, string identityValue);
member this.Contains : System.DirectoryServices.AccountManagement.PrincipalContext * System.DirectoryServices.AccountManagement.IdentityType * string -> bool
[<System.Security.SecurityCritical>]
member this.Contains : System.DirectoryServices.AccountManagement.PrincipalContext * System.DirectoryServices.AccountManagement.IdentityType * string -> bool
Public Function Contains (context As PrincipalContext, identityType As IdentityType, identityValue As String) As Boolean
Parameters
- context
- PrincipalContext
The PrincipalContext object of the principal.
- identityType
- IdentityType
An IdentityType object that specifies the format of identityValue
.
- identityValue
- String
A string that identifies the principal, in the format specified by identityType
.
Returns
true
if an object matching the identityType
/identityValue
pair is in the collection; otherwise, false
.
- Attributes
Remarks
This function can throw the following exceptions:
Exception | Description |
---|---|
MultipleMatchesException | There are multiple principals matching these parameters. |
ArgumentException | The identityType parameter cannot be empty. |
Applies to
.NET 9 (package-provided) and other versions
Product | Versions |
---|---|
.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 feedback
.NET is an open source project. Select a link to provide feedback: