• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TokenImpersonationLevel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TokenImpersonationLevel的典型用法代码示例。如果您正苦于以下问题:C# TokenImpersonationLevel类的具体用法?C# TokenImpersonationLevel怎么用?C# TokenImpersonationLevel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TokenImpersonationLevel类属于命名空间,在下文中一共展示了TokenImpersonationLevel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: WebRequestHandler

		public WebRequestHandler ()
		{
			allowPipelining = true;
			authenticationLevel = AuthenticationLevel.MutualAuthRequested;
			cachePolicy = System.Net.WebRequest.DefaultCachePolicy;
			continueTimeout = TimeSpan.FromMilliseconds (350);
			impersonationLevel = TokenImpersonationLevel.Delegation;
			maxResponseHeadersLength = HttpWebRequest.DefaultMaximumResponseHeadersLength;
			readWriteTimeout = 300000;
			serverCertificateValidationCallback = null;
			unsafeAuthenticatedConnectionSharing = false;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:12,代码来源:WebRequestHandler.cs


示例17: BeginAuthenticateAsClient

 private IAsyncResult BeginAuthenticateAsClient(
     NetworkCredential credential,
     string targetName,
     ProtectionLevel requiredProtectionLevel,
     TokenImpersonationLevel allowedImpersonationLevel,
     AsyncCallback asyncCallback,
     object asyncState)
 {
     return BeginAuthenticateAsClient(credential, null, targetName,
                                      requiredProtectionLevel, allowedImpersonationLevel,
                                      asyncCallback, asyncState);
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:12,代码来源:NegotiateStream.cs


示例18: KerberosSecurityTokenProvider

        public KerberosSecurityTokenProvider(string servicePrincipalName, TokenImpersonationLevel tokenImpersonationLevel, NetworkCredential networkCredential)
        {
            if (servicePrincipalName == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("servicePrincipalName");
            if (tokenImpersonationLevel != TokenImpersonationLevel.Identification && tokenImpersonationLevel != TokenImpersonationLevel.Impersonation)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("tokenImpersonationLevel",
                    SR.GetString(SR.ImpersonationLevelNotSupported, tokenImpersonationLevel)));
            }

            this.servicePrincipalName = servicePrincipalName;
            this.tokenImpersonationLevel = tokenImpersonationLevel;
            this.networkCredential = networkCredential;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:14,代码来源:KerberosSecurityTokenProvider.cs


示例19: OverlappingPipeClientStream

 /// <summary>
 /// Initializes a new instance of the <see cref="OverlappingPipeClientStream"/> class.
 /// </summary>
 /// <param name="serverName">Name of the server.</param>
 /// <param name="pipeName">Name of the pipe.</param>
 /// <param name="transmissionMode"></param>
 /// <param name="impersonationLevel">The impersonation level.</param>
 /// <param name="inheritability">The inheritability.</param>
 public OverlappingPipeClientStream(
     [NotNull] string serverName,
     [NotNull] string pipeName,
     PipeTransmissionMode transmissionMode,
     TokenImpersonationLevel impersonationLevel = TokenImpersonationLevel.None,
     HandleInheritability inheritability = HandleInheritability.None)
     : base(new NamedPipeClientStream(
                serverName,
                pipeName,
                PipeDirection.InOut,
                PipeOptions.Asynchronous,
                impersonationLevel,
                inheritability))
 {
     Debug.Assert(Stream != null);
     ReadMode = transmissionMode;
 }
开发者ID:webappsuk,项目名称:CoreLibraries,代码行数:25,代码来源:OverlappingPipeClientStream.cs


示例20: NamedPipeClientStream

 public NamedPipeClientStream(string serverName, string pipeName, PipeAccessRights desiredAccessRights, PipeOptions options, TokenImpersonationLevel impersonationLevel, HandleInheritability inheritability) : base(DirectionFromRights(desiredAccessRights), 0)
 {
     if (pipeName == null)
     {
         throw new ArgumentNullException("pipeName");
     }
     if (serverName == null)
     {
         throw new ArgumentNullException("serverName", System.SR.GetString("ArgumentNull_ServerName"));
     }
     if (pipeName.Length == 0)
     {
         throw new ArgumentException(System.SR.GetString("Argument_NeedNonemptyPipeName"));
     }
     if (serverName.Length == 0)
     {
         throw new ArgumentException(System.SR.GetString("Argument_EmptyServerName"));
     }
     if ((options & ~(PipeOptions.Asynchronous | PipeOptions.WriteThrough)) != PipeOptions.None)
     {
         throw new ArgumentOutOfRangeException("options", System.SR.GetString("ArgumentOutOfRange_OptionsInvalid"));
     }
     if ((impersonationLevel < TokenImpersonationLevel.None) || (impersonationLevel > TokenImpersonationLevel.Delegation))
     {
         throw new ArgumentOutOfRangeException("impersonationLevel", System.SR.GetString("ArgumentOutOfRange_ImpersonationInvalid"));
     }
     if ((inheritability < HandleInheritability.None) || (inheritability > HandleInheritability.Inheritable))
     {
         throw new ArgumentOutOfRangeException("inheritability", System.SR.GetString("ArgumentOutOfRange_HandleInheritabilityNoneOrInheritable"));
     }
     if ((desiredAccessRights & ~(PipeAccessRights.AccessSystemSecurity | PipeAccessRights.FullControl)) != 0)
     {
         throw new ArgumentOutOfRangeException("desiredAccessRights", System.SR.GetString("ArgumentOutOfRange_InvalidPipeAccessRights"));
     }
     this.m_normalizedPipePath = Path.GetFullPath(@"\\" + serverName + @"\pipe\" + pipeName);
     if (string.Compare(this.m_normalizedPipePath, @"\\.\pipe\anonymous", StringComparison.OrdinalIgnoreCase) == 0)
     {
         throw new ArgumentOutOfRangeException("pipeName", System.SR.GetString("ArgumentOutOfRange_AnonymousReserved"));
     }
     this.m_inheritability = inheritability;
     this.m_impersonationLevel = impersonationLevel;
     this.m_pipeOptions = options;
     this.m_access = (int) desiredAccessRights;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:44,代码来源:NamedPipeClientStream.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TokenInfo类代码示例发布时间:2022-05-24
下一篇:
C# TokenId类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap