本文整理汇总了C#中TokenImpersonationLevel类的典型用法代码示例。如果您正苦于以下问题:C# TokenImpersonationLevel类的具体用法?C# TokenImpersonationLevel怎么用?C# TokenImpersonationLevel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TokenImpersonationLevel类属于命名空间,在下文中一共展示了TokenImpersonationLevel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateCreateContext
internal void ValidateCreateContext(
string package,
NetworkCredential credential,
string servicePrincipalName,
ExtendedProtectionPolicy policy,
ProtectionLevel protectionLevel,
TokenImpersonationLevel impersonationLevel)
{
if (policy != null)
{
// One of these must be set if EP is turned on
if (policy.CustomChannelBinding == null && policy.CustomServiceNames == null)
{
throw new ArgumentException(SR.net_auth_must_specify_extended_protection_scheme, nameof(policy));
}
_extendedProtectionPolicy = policy;
}
else
{
_extendedProtectionPolicy = new ExtendedProtectionPolicy(PolicyEnforcement.Never);
}
ValidateCreateContext(package, true, credential, servicePrincipalName, _extendedProtectionPolicy.CustomChannelBinding, protectionLevel, impersonationLevel);
}
示例2: Compare
internal static int Compare(TokenImpersonationLevel x, TokenImpersonationLevel y)
{
int num = 0;
if (x == y)
{
return num;
}
switch (x)
{
case TokenImpersonationLevel.Identification:
return -1;
case TokenImpersonationLevel.Impersonation:
switch (y)
{
case TokenImpersonationLevel.Identification:
return 1;
case TokenImpersonationLevel.Delegation:
return -1;
}
break;
case TokenImpersonationLevel.Delegation:
return 1;
default:
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnumArgumentException("x", (int) x, typeof(TokenImpersonationLevel)));
}
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnumArgumentException("y", (int) y, typeof(TokenImpersonationLevel)));
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:31,代码来源:TokenImpersonationLevelHelper.cs
示例3: CreateWindowsIdentity
public static WindowsIdentity CreateWindowsIdentity(string userName, string password, TokenImpersonationLevel tokenImpersonationLevel)
{
IntPtr token = IntPtr.Zero;
IntPtr duplicateToken = IntPtr.Zero;
if (LogonUser(userName, string.Empty, password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref token))
{
int impersonationLevel;
switch (tokenImpersonationLevel)
{
case TokenImpersonationLevel.Anonymous:
{ impersonationLevel = 0; break; }
case TokenImpersonationLevel.Impersonation:
{ impersonationLevel = 2; break; }
case TokenImpersonationLevel.Delegation:
{ impersonationLevel = 3; break; }
default:
{ impersonationLevel = 1; break; }
}
if (DuplicateToken(token, impersonationLevel, ref duplicateToken))
{
return new WindowsIdentity(duplicateToken);
}
else
{
throw new InvalidOperationException(string.Format("创建模拟令牌失败 (错误代码: {0}) ", Marshal.GetLastWin32Error()));
}
}
else
{
throw new InvalidOperationException(string.Format("用户登录失败 (错误代码: {0}) ", Marshal.GetLastWin32Error()));
}
}
示例4: AuthenticateAsClient
//
public virtual void AuthenticateAsClient( NetworkCredential credential,
string targetName,
ProtectionLevel requiredProtectionLevel, //this will be the ultimate result or exception
TokenImpersonationLevel allowedImpersonationLevel) //this OR LOWER will be ultimate result in auth context
{
AuthenticateAsClient(credential, null, targetName, requiredProtectionLevel, allowedImpersonationLevel);
}
示例5: SspiSecurityToken
public SspiSecurityToken(TokenImpersonationLevel impersonationLevel, bool allowNtlm, NetworkCredential networkCredential)
{
_impersonationLevel = impersonationLevel;
_allowNtlm = allowNtlm;
_networkCredential = SecurityUtils.GetNetworkCredentialsCopy(networkCredential);
_effectiveTime = DateTime.UtcNow;
_expirationTime = _effectiveTime.AddHours(10);
}
示例6: SspiSecurityToken
public SspiSecurityToken(TokenImpersonationLevel impersonationLevel, bool allowNtlm, System.Net.NetworkCredential networkCredential)
{
this.impersonationLevel = impersonationLevel;
this.allowNtlm = allowNtlm;
this.networkCredential = System.ServiceModel.Security.SecurityUtils.GetNetworkCredentialsCopy(networkCredential);
this.effectiveTime = DateTime.UtcNow;
this.expirationTime = this.effectiveTime.AddHours(10.0);
}
示例7: ValidateImpersonationLevel
internal static void ValidateImpersonationLevel(TokenImpersonationLevel impersonationLevel)
{
if (impersonationLevel != TokenImpersonationLevel.Identification)
{
throw new ArgumentOutOfRangeException(nameof(impersonationLevel), impersonationLevel.ToString(),
SR.net_auth_supported_impl_levels);
}
}
示例8: IsDefined
internal static bool IsDefined(TokenImpersonationLevel value)
{
if (((value != TokenImpersonationLevel.None) && (value != TokenImpersonationLevel.Anonymous)) && ((value != TokenImpersonationLevel.Identification) && (value != TokenImpersonationLevel.Impersonation)))
{
return (value == TokenImpersonationLevel.Delegation);
}
return true;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:TokenImpersonationLevelHelper.cs
示例9: SspiSecurityTokenProvider
public SspiSecurityTokenProvider (NetworkCredential credential,
bool allowNtlm, TokenImpersonationLevel impersonationLevel)
{
if (credential == null)
throw new ArgumentNullException ("credential");
this.credential = credential;
allow_ntlm = allowNtlm;
impersonation_level = impersonationLevel;
}
示例10: ValidateCreateContext
internal void ValidateCreateContext(string package,
NetworkCredential credential,
string servicePrincipalName,
ExtendedProtectionPolicy policy,
ProtectionLevel protectionLevel,
TokenImpersonationLevel impersonationLevel)
{
throw new PlatformNotSupportedException();
}
示例11: TokenImpersonationLevelHelper
static TokenImpersonationLevelHelper()
{
TokenImpersonationLevel[] levelArray = new TokenImpersonationLevel[5];
levelArray[1] = TokenImpersonationLevel.Anonymous;
levelArray[2] = TokenImpersonationLevel.Identification;
levelArray[3] = TokenImpersonationLevel.Impersonation;
levelArray[4] = TokenImpersonationLevel.Delegation;
TokenImpersonationLevelOrder = levelArray;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:TokenImpersonationLevelHelper.cs
示例12: SpnegoTokenProvider
public SpnegoTokenProvider(System.IdentityModel.SafeFreeCredentials credentialsHandle, SecurityBindingElement securityBindingElement) : base(securityBindingElement)
{
this.allowedImpersonationLevel = TokenImpersonationLevel.Identification;
this.identityVerifier = System.ServiceModel.Security.IdentityVerifier.CreateDefault();
this.allowNtlm = true;
this.authenticateServer = true;
this.interactiveNegoExLogonEnabled = true;
this.credentialsHandle = credentialsHandle;
}
示例13: IpcClientTransportSink
internal IpcClientTransportSink(string channelURI, IpcClientChannel channel)
{
string str;
this.portCache = new ConnectionCache();
this._tokenImpersonationLevel = TokenImpersonationLevel.Identification;
this._timeout = 0x3e8;
this._channel = channel;
string str2 = IpcChannelHelper.ParseURL(channelURI, out str);
int startIndex = str2.IndexOf("://") + 3;
this._portName = str2.Substring(startIndex);
}
示例14: WebRequestChannel
public WebRequestChannel()
{
// Set HWR default values
this.allowPipelining = true;
this.authenticationLevel = AuthenticationLevel.MutualAuthRequested;
this.cachePolicy = WebRequest.DefaultCachePolicy;
this.impersonationLevel = TokenImpersonationLevel.Delegation;
this.maxResponseHeadersLength = HttpWebRequest.DefaultMaximumResponseHeadersLength;
this.readWriteTimeout = 5 * 60 * 1000; // 5 minutes
this.unsafeAuthenticatedConnectionSharing = false;
}
示例15: WindowsClientCredential
internal WindowsClientCredential(WindowsClientCredential other)
{
this.allowedImpersonationLevel = TokenImpersonationLevel.Identification;
this.allowNtlm = true;
if (other.windowsCredentials != null)
{
this.windowsCredentials = System.ServiceModel.Security.SecurityUtils.GetNetworkCredentialsCopy(other.windowsCredentials);
}
this.allowedImpersonationLevel = other.allowedImpersonationLevel;
this.allowNtlm = other.allowNtlm;
this.isReadOnly = other.isReadOnly;
}