Exemplo n.º 1
0
 public CredentialValidator(ContextType contextType, string serverName, ServerProperties serverProperties)
 {
     this.fastConcurrentSupported = true;
     this.connCache               = new Hashtable(4);
     this.cacheLock               = new object();
     this.lastBindMethod          = CredentialValidator.AuthMethod.Simple;
     this.fastConcurrentSupported = serverProperties.OsVersion != DomainControllerMode.Win2k;
     if (contextType != ContextType.Machine || serverName != null)
     {
         this.serverName = serverName;
     }
     else
     {
         this.serverName = Environment.MachineName;
     }
     this.contextType      = contextType;
     this.serverProperties = serverProperties;
 }
Exemplo n.º 2
0
		public CredentialValidator(ContextType contextType, string serverName, ServerProperties serverProperties)
		{
			this.fastConcurrentSupported = true;
			this.connCache = new Hashtable(4);
			this.cacheLock = new object();
			this.lastBindMethod = CredentialValidator.AuthMethod.Simple;
			this.fastConcurrentSupported = serverProperties.OsVersion != DomainControllerMode.Win2k;
			if (contextType != ContextType.Machine || serverName != null)
			{
				this.serverName = serverName;
			}
			else
			{
				this.serverName = Environment.MachineName;
			}
			this.contextType = contextType;
			this.serverProperties = serverProperties;
		}
Exemplo n.º 3
0
        public bool Validate(string userName, string password)
        {
            bool flag;
            NetworkCredential networkCredential = new NetworkCredential(userName, password);

            if (userName == null || userName.Length != 0)
            {
                if (this.contextType == ContextType.Domain || this.contextType == ContextType.ApplicationDirectory)
                {
                    try
                    {
                        if (this.lastBindMethod != CredentialValidator.AuthMethod.Simple || !this.fastConcurrentSupported && this.contextType != ContextType.ApplicationDirectory)
                        {
                            try
                            {
                                this.BindLdap(networkCredential, ContextOptions.Negotiate | ContextOptions.Signing | ContextOptions.Sealing);
                                this.lastBindMethod = CredentialValidator.AuthMethod.Negotiate;
                                flag = true;
                                return(flag);
                            }
                            catch (LdapException ldapException)
                            {
                            }
                            this.BindLdap(networkCredential, ContextOptions.SimpleBind | ContextOptions.SecureSocketLayer);
                            this.lastBindMethod = CredentialValidator.AuthMethod.Simple;
                            flag = true;
                        }
                        else
                        {
                            try
                            {
                                this.BindLdap(networkCredential, ContextOptions.SimpleBind | ContextOptions.SecureSocketLayer);
                                this.lastBindMethod = CredentialValidator.AuthMethod.Simple;
                                flag = true;
                                return(flag);
                            }
                            catch (LdapException ldapException1)
                            {
                            }
                            this.BindLdap(networkCredential, ContextOptions.Negotiate | ContextOptions.Signing | ContextOptions.Sealing);
                            this.lastBindMethod = CredentialValidator.AuthMethod.Negotiate;
                            flag = true;
                        }
                    }
                    catch (LdapException ldapException3)
                    {
                        LdapException ldapException2 = ldapException3;
                        if ((long)ldapException2.ErrorCode != (long)ExceptionHelper.ERROR_LOGON_FAILURE)
                        {
                            throw;
                        }
                        else
                        {
                            flag = false;
                        }
                    }
                    return(flag);
                }
                else
                {
                    return(this.BindSam(this.serverName, userName, password));
                }
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
		public bool Validate(string userName, string password)
		{
			bool flag;
			NetworkCredential networkCredential = new NetworkCredential(userName, password);
			if (userName == null || userName.Length != 0)
			{
				if (this.contextType == ContextType.Domain || this.contextType == ContextType.ApplicationDirectory)
				{
					try
					{
						if (this.lastBindMethod != CredentialValidator.AuthMethod.Simple || !this.fastConcurrentSupported && this.contextType != ContextType.ApplicationDirectory)
						{
							try
							{
								this.BindLdap(networkCredential, ContextOptions.Negotiate | ContextOptions.Signing | ContextOptions.Sealing);
								this.lastBindMethod = CredentialValidator.AuthMethod.Negotiate;
								flag = true;
								return flag;
							}
							catch (LdapException ldapException)
							{
							}
							this.BindLdap(networkCredential, ContextOptions.SimpleBind | ContextOptions.SecureSocketLayer);
							this.lastBindMethod = CredentialValidator.AuthMethod.Simple;
							flag = true;
						}
						else
						{
							try
							{
								this.BindLdap(networkCredential, ContextOptions.SimpleBind | ContextOptions.SecureSocketLayer);
								this.lastBindMethod = CredentialValidator.AuthMethod.Simple;
								flag = true;
								return flag;
							}
							catch (LdapException ldapException1)
							{
							}
							this.BindLdap(networkCredential, ContextOptions.Negotiate | ContextOptions.Signing | ContextOptions.Sealing);
							this.lastBindMethod = CredentialValidator.AuthMethod.Negotiate;
							flag = true;
						}
					}
					catch (LdapException ldapException3)
					{
						LdapException ldapException2 = ldapException3;
						if ((long)ldapException2.ErrorCode != (long)ExceptionHelper.ERROR_LOGON_FAILURE)
						{
							throw;
						}
						else
						{
							flag = false;
						}
					}
					return flag;
				}
				else
				{
					return this.BindSam(this.serverName, userName, password);
				}
			}
			else
			{
				return false;
			}
		}