00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef LDAPSESSION_H
00014 #define LDAPSESSION_H
00015 #define LDAP_DEPRECATED 1
00016
00017 #include <ldap.h>
00018 #include <string>
00019 #include <list>
00020 using namespace std;
00021
00022 struct LDAPExeption
00023 {
00024 LDAPExeption(string type,string str){err_type=type;err_str=str;}
00025 string err_type;
00026 string err_str;
00027 };
00028
00029 class ByteArray
00030 {
00031 public:
00032 ByteArray();
00033 ByteArray(const ByteArray&);
00034 ~ByteArray();
00035 const char* getData(){return data;}
00036 string asString(){return data;}
00037 int length(){return size;}
00038 void load(const char*,int);
00039 void fromStdStr(const string&);
00040 void operator =(const ByteArray&);
00041 private:
00042 void _delete();
00043 char* data;
00044 int size;
00045 };
00046
00047
00048 struct LDAPBinValue
00049 {
00050 string attr;
00051 list<ByteArray> value;
00052 };
00053
00054 struct LDAPStringValue
00055 {
00056 string attr;
00057 list<string> value;
00058 };
00059
00060 typedef list<LDAPStringValue> LDAPStringEntry;
00061 typedef list<LDAPBinValue> LDAPBinEntry;
00062
00063 class LDAPSession
00064 {
00065 public:
00066 LDAPSession(string,int,string,string, bool simple=false, bool start_tls=true);
00067 ~LDAPSession();
00068 void addStringValue(string dn,const list<LDAPStringValue>& values);
00069 void remove(string);
00070 static list<string> getStringAttrValues(const LDAPStringEntry& entry,string attr);
00071 static list<ByteArray> getBinAttrValues(const LDAPBinEntry& entry,string attr);
00072 void modifyStringValue(string dn,const list<LDAPStringValue>& values);
00073 void stringSearch(string dn,const list<string> &attributes,string searchParam,list<LDAPStringEntry> &result);
00074 void binSearch(string dn,const list<string> &attributes,string searchParam,list<LDAPBinEntry> &result);
00075
00076 private:
00077 LDAP* ld;
00078 };
00079
00080 #endif