当前位置: 首页>>代码示例>>C#>>正文


C# TokenImpersonationLevel类代码示例

本文整理汇总了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);
        }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:25,代码来源:NegoState.Windows.cs

示例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()));
     }
 }
开发者ID:huoxudong125,项目名称:WCF-Demo,代码行数:32,代码来源:Program.cs

示例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);
 }
开发者ID:uQr,项目名称:referencesource,代码行数:8,代码来源:NegotiateStream.cs

示例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);
 }
开发者ID:smulholland2,项目名称:wcf,代码行数:8,代码来源:SspiSecurityToken.cs

示例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);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:SspiSecurityToken.cs

示例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);
     }
 }
开发者ID:dotnet,项目名称:corefx,代码行数:8,代码来源:NegotiateStreamPal.Unix.cs

示例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;
		}
开发者ID:nickchal,项目名称:pash,代码行数:9,代码来源:SspiSecurityTokenProvider.cs

示例10: ValidateCreateContext

 internal void ValidateCreateContext(string package,
                                     NetworkCredential credential,
                                     string servicePrincipalName,
                                     ExtendedProtectionPolicy policy,
                                     ProtectionLevel protectionLevel,
                                     TokenImpersonationLevel impersonationLevel)
 {
     throw new PlatformNotSupportedException();
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:9,代码来源:NegoState.Unix.cs

示例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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:SpnegoTokenProvider.cs

示例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);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:IpcClientTransportSink.cs

示例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;
 }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:11,代码来源:WebRequestChannel.cs

示例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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:WindowsClientCredential.cs


注:本文中的TokenImpersonationLevel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。