共用方式為


SpnEndpointIdentity 建構函式

定義

初始化 SpnEndpointIdentity 的新執行個體。

多載

SpnEndpointIdentity(Claim)

使用指定的身分識別宣告,初始化 SpnEndpointIdentity 類別的新執行個體。

SpnEndpointIdentity(String)

使用指定的服務主要名稱 (SPN),初始化 SpnEndpointIdentity 類別的新執行個體。

SpnEndpointIdentity(Claim)

來源:
SpnEndpointIdentity.cs
來源:
SpnEndpointIdentity.cs

使用指定的身分識別宣告,初始化 SpnEndpointIdentity 類別的新執行個體。

public:
 SpnEndpointIdentity(System::IdentityModel::Claims::Claim ^ identity);
public SpnEndpointIdentity (System.IdentityModel.Claims.Claim identity);
new System.ServiceModel.SpnEndpointIdentity : System.IdentityModel.Claims.Claim -> System.ServiceModel.SpnEndpointIdentity
Public Sub New (identity As Claim)

參數

identity
Claim

此服務主要名稱 (SPN) 的身分識別。

例外狀況

identitynull

identity 的宣告類型不是 Spn

範例

下列程式碼會顯示如何從一組宣告建立識別。

private SpnEndpointIdentity CreateIdentityFromClaimSet(ClaimSet claims)
{
    foreach (Claim claim in claims.FindClaims(null, Rights.Identity))
    {
        return new SpnEndpointIdentity(claim);
    }
    return null;
}
Private Function CreateIdentityFromClaimSet(ByVal claims As ClaimSet) As SpnEndpointIdentity
    For Each claim As Claim In claims.FindClaims(Nothing, Rights.Identity)
        Return New SpnEndpointIdentity(claim)
    Next claim
    Return Nothing
End Function

備註

此建構函式會將 SpnLookupTime 屬性設定為 1 分鐘。

適用於

SpnEndpointIdentity(String)

來源:
SpnEndpointIdentity.cs
來源:
SpnEndpointIdentity.cs

使用指定的服務主要名稱 (SPN),初始化 SpnEndpointIdentity 類別的新執行個體。

public:
 SpnEndpointIdentity(System::String ^ spnName);
public SpnEndpointIdentity (string spnName);
new System.ServiceModel.SpnEndpointIdentity : string -> System.ServiceModel.SpnEndpointIdentity
Public Sub New (spnName As String)

參數

spnName
String

SPN。

例外狀況

spnNamenull

範例

下列程式碼會顯示如何從 SPN 的字串表示法建立識別。

static EndpointIdentity CreateSpnIdentity()
{
    WindowsIdentity self = WindowsIdentity.GetCurrent();
    SecurityIdentifier sid = self.User;

    SpnEndpointIdentity identity = null;

    identity = new SpnEndpointIdentity(string.Format(CultureInfo.InvariantCulture, "host/{0}", GetMachineName()));

    return identity;
}
static string GetMachineName()
{
    return Dns.GetHostEntry(string.Empty).HostName;
}
Private Shared Function CreateSpnIdentity() As EndpointIdentity
    Dim self As WindowsIdentity = WindowsIdentity.GetCurrent()
    Dim sid As SecurityIdentifier = self.User

    Dim identity As SpnEndpointIdentity = Nothing

    identity = New SpnEndpointIdentity(String.Format(CultureInfo.InvariantCulture, "host/{0}", GetMachineName()))

    Return identity
End Function
Private Shared Function GetMachineName() As String
    Return Dns.GetHostEntry(String.Empty).HostName
End Function

備註

此建構函式會將 SpnLookupTime 屬性設定為 1 分鐘。

適用於