Source Code (Use browser search to find items of interest.)
Class Index
kioslave'Connection (./kdebase/kioslave/ldap/kldap.h:103)
class Connection : public LDAPBase
{
friend class Request;
public:
/**
* Constructor. Creates a LDAP connection.
*
* The constructor creates a new LDAP connection.
* Note that the constructor does NOT connect to the
* server immediately. This must be done via the
* connect() method.
*
* param s the server to connect, defaults to "localhost"
* param p the port on the server, defaults to 389.
*
*/
Connection(const char *s="localhost", int p=LDAP_PORT);
/**
* Destructor. Destroys the connection.
*
* The destructor disconnects from the server, is
* the connection was still active.
*
*/
~Connection();
/**
* Connects to the LDAP server.
*
* This method actually connects to the server and
* activates the connection.
*
* @return TRUE, if connections was established, else FALSE
*/
bool connect();
/**
* Disconnects from the server.
*
* This method closes an active connection with a LDAP
* server.
*
* @return TRUE, if the connection was closed, else FALSE
*
*/
bool disconnect();
/**
* Returns the state of the connection.
*
* This method tells if the connection to the server is
* currently active.
*
* @return TRUE, if connected to the server, else FALSE
*
*/
bool isConnected() { return handle() != 0; };
/**
* Authenticates to the server.
*
* This method is used to authenticate to the server.
*
* Some servers require the user to authenticate before
* operations are allowed. Currently, there are two authentication
* methods:
*
* Simple authentication using a password.
* Kerberos authentication using a ticket.
*
* Please note that LDAP does not provide a high level of
* security. Especially simple authentication over
* unencrypted lines is dangerous.
*
* @param dn Distinguished name of the entity to authorize as.
* @param cred The credentials (e.g. the password)
* @param method The authentication method.
* @return TRUE, if authentication was successfull, else FALSE.
*
*/
bool authenticate(const char *dn=0, const char *cred=0, int method=LDAP_AUTH_SIMPLE);
/// Returns the host to connect to.
QString host() { return _server; };
/// Sets the host to connect to.
void setHost(const QString &host) { _server=host; };
/// Returns the port for the connection.
int port() { return _port; }
/// Sets the port for the connection.
void setPort(int port) { _port=port; };
private:
QString _server;
int _port;
};
/**
* A LDAP attribute.
*
* This class encapsulates a LDAP attribute.
* Attributes are returned as results of queries.
*
* Note that an attribute can have more than one value.
* In fact, most attributes have several values.
*
* @short A LDAP attribute.
* @author Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
* @version $Id: kldap.h,v 1.1.1.1 1999/08/09 16:07:21 hoelzer Exp $
*
*/
kioslave'Connection::Connection() (./kdebase/kioslave/ldap/kldap.cpp:37)
Connection::Connection(const char *s, int p)
: LDAPBase(), _server(s), _port(p)
{
}
kioslave'Connection::~Connection() (./kdebase/kioslave/ldap/kldap.cpp:43)
Connection::~Connection()
{
disconnect();
}
kioslave'Connection::connect() (./kdebase/kioslave/ldap/kldap.cpp:49)
bool Connection::connect()
{
// if we are already connected, it is better to disconnect now
if (handle())
disconnect();
// try to connect to the server
_handle = ldap_open(const_cast<char*>(_server.ascii()), _port);
debug << "open connection to " << _server << ":" << _port;
debug << ((handle() != 0) ? " succeeded" : " failed") << endl;
// test if connect succeeded
return handle() != 0;
}
kioslave'Connection::disconnect() (./kdebase/kioslave/ldap/kldap.cpp:66)
bool Connection::disconnect()
{
// test if we are really connected
if (!handle())
return TRUE;
debug << "close connection to " << _server << ":" << _port;
// close the connection to the server
check(ldap_unbind(handle()));
_handle = 0;
return result() == LDAP_SUCCESS;
}
kioslave'Connection::authenticate() (./kdebase/kioslave/ldap/kldap.cpp:82)
bool Connection::authenticate(const char *dn, const char *cred, int method)
{
if (!handle())
return FALSE;
debug << "authentication";
return check(ldap_bind_s(handle(), const_cast<char*>(dn), const_cast<char*>(cred), method));
}