共用方式為


PrincipalCollection.Contains 方法

定義

傳回值,指出所指定 Principal 是否為 PrincipalCollection 的成員。 Principal 可使用與 Add 方法相同的方式指定。

多載

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)

來源:
PrincipalCollection.cs
來源:
PrincipalCollection.cs
來源:
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)

來源:
PrincipalCollection.cs
來源:
PrincipalCollection.cs
來源:
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)

來源:
PrincipalCollection.cs
來源:
PrincipalCollection.cs
來源:
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)

來源:
PrincipalCollection.cs
來源:
PrincipalCollection.cs
來源:
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)

來源:
PrincipalCollection.cs
來源:
PrincipalCollection.cs
來源:
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 不能是空的。

適用於