public LdapConnection(LdapDirectoryIdentifier identifier, NetworkCredential credential, System.DirectoryServices.Protocols.AuthType authType)
 {
     this.connectionAuthType = System.DirectoryServices.Protocols.AuthType.Negotiate;
     this.ldapHandle = IntPtr.Zero;
     this.automaticBind = true;
     this.needDispose = true;
     this.fd = new GetLdapResponseCallback(this.ConstructResponse);
     base.directoryIdentifier = identifier;
     base.directoryCredential = (credential != null) ? new NetworkCredential(credential.UserName, credential.Password, credential.Domain) : null;
     this.connectionAuthType = authType;
     if ((authType < System.DirectoryServices.Protocols.AuthType.Anonymous) || (authType > System.DirectoryServices.Protocols.AuthType.Kerberos))
     {
         throw new InvalidEnumArgumentException("authType", (int) authType, typeof(System.DirectoryServices.Protocols.AuthType));
     }
     if (((this.AuthType == System.DirectoryServices.Protocols.AuthType.Anonymous) && (base.directoryCredential != null)) && (((base.directoryCredential.Password != null) && (base.directoryCredential.Password.Length != 0)) || ((base.directoryCredential.UserName != null) && (base.directoryCredential.UserName.Length != 0))))
     {
         throw new ArgumentException(System.DirectoryServices.Protocols.Res.GetString("InvalidAuthCredential"));
     }
     this.Init();
     this.options = new LdapSessionOptions(this);
     this.clientCertificateRoutine = new QUERYCLIENTCERT(this.ProcessClientCertificate);
 }
Exemplo n.º 2
0
 internal LdapConnection(LdapDirectoryIdentifier identifier, NetworkCredential credential, AuthType authType, IntPtr handle)
 {
     directoryIdentifier = identifier;
     needDispose = false;
     ldapHandle = new ConnectionHandle(handle, needDispose);
     directoryCredential = credential;
     _connectionAuthType = authType;
     _options = new LdapSessionOptions(this);
     clientCertificateRoutine = new QUERYCLIENTCERT(ProcessClientCertificate);
 }
Exemplo n.º 3
0
        public LdapConnection(LdapDirectoryIdentifier identifier, NetworkCredential credential, AuthType authType)
        {
            _fd = new GetLdapResponseCallback(ConstructResponse);
            directoryIdentifier = identifier;
            directoryCredential = (credential != null) ? new NetworkCredential(credential.UserName, credential.Password, credential.Domain) : null;

            _connectionAuthType = authType;

            if (authType < AuthType.Anonymous || authType > AuthType.Kerberos)
                throw new InvalidEnumArgumentException("authType", (int)authType, typeof(AuthType));

            // if user wants to do anonymous bind, but specifies credential, error out
            if (AuthType == AuthType.Anonymous && (directoryCredential != null && ((directoryCredential.Password != null && directoryCredential.Password.Length != 0) || (directoryCredential.UserName != null && directoryCredential.UserName.Length != 0))))
                throw new ArgumentException(Res.GetString(Res.InvalidAuthCredential));

            Init();
            _options = new LdapSessionOptions(this);
            clientCertificateRoutine = new QUERYCLIENTCERT(ProcessClientCertificate);
        }
Exemplo n.º 4
0
		internal LdapConnection(LdapDirectoryIdentifier identifier, NetworkCredential credential, AuthType authType, IntPtr handle)
		{
			this.connectionAuthType = AuthType.Negotiate;
			this.automaticBind = true;
			this.needDispose = true;
			this.directoryIdentifier = identifier;
			this.ldapHandle = new ConnectionHandle(handle);
			this.directoryCredential = credential;
			this.connectionAuthType = authType;
			this.options = new LdapSessionOptions(this);
			this.needDispose = false;
			this.clientCertificateRoutine = new QUERYCLIENTCERT(this.ProcessClientCertificate);
		}
Exemplo n.º 5
0
		public LdapConnection(LdapDirectoryIdentifier identifier, NetworkCredential credential, AuthType authType)
		{
			NetworkCredential networkCredential;
			this.connectionAuthType = AuthType.Negotiate;
			this.automaticBind = true;
			this.needDispose = true;
			this.fd = new GetLdapResponseCallback(this.ConstructResponse);
			this.directoryIdentifier = identifier;
			LdapConnection ldapConnection = this;
			if (credential != null)
			{
				networkCredential = new NetworkCredential(credential.UserName, credential.Password, credential.Domain);
			}
			else
			{
				networkCredential = null;
			}
			ldapConnection.directoryCredential = networkCredential;
			this.connectionAuthType = authType;
			if (authType < AuthType.Anonymous || authType > AuthType.Kerberos)
			{
				throw new InvalidEnumArgumentException("authType", (int)authType, typeof(AuthType));
			}
			else
			{
				if (this.AuthType != AuthType.Anonymous || this.directoryCredential == null || (this.directoryCredential.Password == null || this.directoryCredential.Password.Length == 0) && (this.directoryCredential.UserName == null || this.directoryCredential.UserName.Length == 0))
				{
					this.Init();
					this.options = new LdapSessionOptions(this);
					this.clientCertificateRoutine = new QUERYCLIENTCERT(this.ProcessClientCertificate);
					return;
				}
				else
				{
					throw new ArgumentException(Res.GetString("InvalidAuthCredential"));
				}
			}
		}