Novell.Directory.Ldap.LdapConnection.Disconnect C# (CSharp) Method

Disconnect() public method

Synchronously disconnects from the Ldap server. Before the object can perform Ldap operations again, it must reconnect to the server by calling connect. The disconnect method abandons any outstanding requests, issues an unbind request to the server, and then closes the socket.
LdapException A general exception which includes an error /// message and an Ldap error code. /// ///
public Disconnect ( ) : void
return void
        public virtual void Disconnect()
        {
            // disconnect from API call
            Disconnect(defSearchCons, true);
            return ;
        }

Same methods

LdapConnection::Disconnect ( LdapConstraints cons ) : void
LdapConnection::Disconnect ( LdapConstraints cons, bool how ) : void

Usage Example

        public bool CheckUser(string UserName, string OldPassword)
        {
            bool   result = true;
            string User   = UserName;
            string Pass   = OldPassword;

            // Creating an LdapConnection instance
            Novell.Directory.Ldap.LdapConnection ldapConn = new Novell.Directory.Ldap.LdapConnection();

            string dn = "uid = " + UserName + ",ou=users,dc=example,dc=com";

            try
            {
                //Connect function will create a socket connection to the server
                ldapConn.Connect(ldapHost, ldapPort);

                //Bind function will Bind the user object Credentials to the Server
                ldapConn.Bind(dn, OldPassword);
            }

            catch (Novell.Directory.Ldap.LdapException e)
            {
                TempData["msg"] = "<script>alert('Could not authenticate user!');</script>";
                result          = false;
                return(result);
            }

            finally
            {
                // Disconnect from LDAP
                ldapConn.Disconnect();
            }

            return(result);
        }
All Usage Examples Of Novell.Directory.Ldap.LdapConnection::Disconnect