本文整理汇总了C#中ClientInfo.SetClientUser方法的典型用法代码示例。如果您正苦于以下问题:C# ClientInfo.SetClientUser方法的具体用法?C# ClientInfo.SetClientUser怎么用?C# ClientInfo.SetClientUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClientInfo
的用法示例。
在下文中一共展示了ClientInfo.SetClientUser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifySecurity
private bool VerifySecurity(ClientInfo client)
{
// Set current thread principal to remote client's user principal.
if (!(Thread.CurrentPrincipal is WindowsPrincipal))
Thread.CurrentPrincipal = client.ClientUser;
// Retrieve previously initialized security provider of the remote client's user.
if (SecurityProviderCache.CurrentProvider == null)
SecurityProviderCache.CurrentProvider = SecurityProviderUtility.CreateProvider(string.Empty);
// Initialize security provider for the remote client's user from specified credentials.
if (!Thread.CurrentPrincipal.Identity.IsAuthenticated &&
!string.IsNullOrEmpty(client.ClientUserCredentials))
{
string[] credentialParts = client.ClientUserCredentials.Split(':');
if (credentialParts.Length == 2)
{
ISecurityProvider provider = SecurityProviderUtility.CreateProvider(credentialParts[0]);
provider.Initialize();
if (provider.Authenticate(credentialParts[1]))
SecurityProviderCache.CurrentProvider = provider;
}
}
// Save the initialized security provider of remote client's user for subsequent uses.
if (client.ClientUser != Thread.CurrentPrincipal)
client.SetClientUser(Thread.CurrentPrincipal);
return client.ClientUser.Identity.IsAuthenticated;
}