00001
00002
00003
00004
00005
00006
00007 #ifndef LDAP_CONNECTION_H
00008 #define LDAP_CONNECTION_H
00009
00010 #include <LDAPSearchResults.h>
00011 #include <LDAPExtResult.h>
00012 #include <LDAPAsynConnection.h>
00013
00021 class LDAPConnection : private LDAPAsynConnection {
00022
00023 public :
00028 static const int SEARCH_BASE;
00029
00034 static const int SEARCH_ONE;
00035
00040 static const int SEARCH_SUB;
00041
00051 LDAPConnection(const std::string& hostname="localhost", int port=389,
00052 LDAPConstraints* cons=new LDAPConstraints());
00053
00057 ~LDAPConnection();
00058
00070 void init(const std::string& hostname, int port);
00071
00079 void start_tls();
00080
00090 void bind(const std::string& dn="", const std::string& passwd="",
00091 LDAPConstraints* cons=0);
00092 void saslInteractiveBind(const std::string& mech,
00093 int flags=0,
00094 SaslInteractionHandler *sih=0,
00095 const LDAPConstraints *cons=0);
00096
00102 void unbind();
00103
00121 bool compare(const std::string& dn, const LDAPAttribute& attr,
00122 LDAPConstraints* cons=0);
00123
00135 void del(const std::string& dn, const LDAPConstraints* cons=0);
00136
00147 void add(const LDAPEntry* le, const LDAPConstraints* cons=0);
00148
00160 void modify(const std::string& dn, const LDAPModList* mods,
00161 const LDAPConstraints* cons=0);
00162
00183 void rename(const std::string& dn, const std::string& newRDN,
00184 bool delOldRDN=false, const std::string& newParentDN="",
00185 const LDAPConstraints* cons=0);
00186
00208 LDAPSearchResults* search(const std::string& base, int scope=0,
00209 const std::string& filter="objectClass=*",
00210 const StringList& attrs=StringList(), bool attrsOnly=false,
00211 const LDAPConstraints* cons=0);
00212
00228 LDAPExtResult* extOperation(const std::string& oid, const std::string&
00229 value="", const LDAPConstraints *const = 0);
00230
00231 const std::string& getHost() const;
00232
00233 int getPort() const;
00234
00235 void setConstraints(LDAPConstraints *cons);
00236
00237 const LDAPConstraints* getConstraints() const ;
00238 TlsOptions getTlsOptions() const;
00239 };
00240
00241 #endif //LDAP_CONNECTION_H