PrincipalCollection.Contains 方法

定义

返回一个值,该值指示指定的 Principal 是否是 PrincipalCollection 的成员。 可以采用与 Add 方法中相同的方式指定 Principal

重载

Contains(ComputerPrincipal)

返回一个值,该值指示集合是否包含指定的 ComputerPrincipal 对象。

Contains(GroupPrincipal)

返回一个值,该值指示集合是否包含指定的 GroupPrincipal 对象。

Contains(Principal)

返回一个值,该值指示集合是否包含指定的 Principal 对象。

Contains(UserPrincipal)

返回一个值,该值指示集合是否包含指定的 UserPrincipal 对象。

Contains(PrincipalContext, IdentityType, String)

返回一个值,该值指示匹配 identityType/identityValue 对的 Principal 对象是否位于集合中。

注解

与 一 Add样, Remove 此函数有四个重载,但它们都执行相同操作。 实现额外的重载只是为了提高可用性,以便使用 IntelliSense 的开发人员看到采用 UserPrincipalGroupPrincipalComputerPrincipal 对象的重载。 调用用户、组或计算机重载中的任何一个与调用 Principal 重载完全等效。

Contains(ComputerPrincipal)

Source:
PrincipalCollection.cs
Source:
PrincipalCollection.cs
Source:
PrincipalCollection.cs

返回一个值,该值指示集合是否包含指定的 ComputerPrincipal 对象。

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

参数

返回

当集合包含指定的对象时为 true;否则为 false

属性

适用于

Contains(GroupPrincipal)

Source:
PrincipalCollection.cs
Source:
PrincipalCollection.cs
Source:
PrincipalCollection.cs

返回一个值,该值指示集合是否包含指定的 GroupPrincipal 对象。

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

参数

group
GroupPrincipal

GroupPrincipal 对象。

返回

当集合包含指定的对象时为 true;否则为 false

属性

适用于

Contains(Principal)

Source:
PrincipalCollection.cs
Source:
PrincipalCollection.cs
Source:
PrincipalCollection.cs

返回一个值,该值指示集合是否包含指定的 Principal 对象。

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

参数

principal
Principal

Principal 对象。

返回

当集合包含指定的对象时为 true;否则为 false

实现

属性

适用于

Contains(UserPrincipal)

Source:
PrincipalCollection.cs
Source:
PrincipalCollection.cs
Source:
PrincipalCollection.cs

返回一个值,该值指示集合是否包含指定的 UserPrincipal 对象。

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

参数

user
UserPrincipal

UserPrincipal 对象。

返回

当集合包含指定的对象时为 true;否则为 false

属性

适用于

Contains(PrincipalContext, IdentityType, String)

Source:
PrincipalCollection.cs
Source:
PrincipalCollection.cs
Source:
PrincipalCollection.cs

返回一个值,该值指示匹配 identityType/identityValue 对的 Principal 对象是否位于集合中。

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

参数

context
PrincipalContext

主体的 PrincipalContext 对象。

identityType
IdentityType

一个 IdentityType 指定 格式的 identityValue对象。

identityValue
String

标识主体的字符串,格式由 identityType指定。

返回

如果与 identityType/identityValue 对匹配的对象位于集合中,则为 true;否则为 false

属性

注解

此函数可能会引发以下异常:

例外 描述
MultipleMatchesException 有多个主体与这些参数匹配。
ArgumentException 参数 identityType 不能为空。

适用于