00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _LdapAgent_h
00011 #define _LdapAgent_h
00012
00013 #include <Y2.h>
00014 #include <scr/SCRAgent.h>
00015
00016 #include <LDAPConnection.h>
00017 #include <LDAPException.h>
00018 #include <LDAPReferralException.h>
00019 #include <LDAPAttributeList.h>
00020 #include <LDAPAttribute.h>
00021
00022 #include <LDAPSchema.h>
00023
00024 #define DEFAULT_PORT 389
00025 #define ANSWER 42
00026 #define MAX_LENGTH_ID 5
00027
00031 class LdapAgent : public SCRAgent
00032 {
00033 private:
00037 int port;
00038 string hostname;
00039 string bind_dn;
00040 string bind_pw;
00041 string ldap_error;
00042 string server_error;
00043
00044 int ldap_error_code;
00045 bool ldap_initialized;
00046
00047 string userpw_hash;
00048
00049 LDAPConnection *ldap;
00050 LDAPConstraints *cons;
00051 LDAPSchema *schema;
00052
00053 YCPMap users,
00054 users_by_name,
00055 users_by_uidnumber,
00056 usernames,
00057 userdns,
00058 uids,
00059 homes,
00060 user_items,
00061 groups,
00062 groups_by_name,
00063 groups_by_gidnumber,
00064 groupnames,
00065 gids,
00066 group_items;
00067
00072 string getValue ( const YCPMap map, const string key);
00073
00080 int getIntValue ( const YCPMap map, const string key, int deflt);
00081
00082 bool getBoolValue (const YCPMap map, const string key);
00083
00084 YCPList getListValue (const YCPMap map, const string key);
00085
00089 StringList ycplist2stringlist (YCPList l);
00090
00094 YCPList stringlist2ycplist (StringList sl);
00095
00099 YCPList stringlist2ycplist_low (StringList sl);
00100
00106 YCPMap getGroupEntry (LDAPEntry *entry, string member_attribute);
00107
00112 YCPMap getUserEntry (LDAPEntry *entry);
00113
00119 YCPMap getSearchedEntry (LDAPEntry *entry, bool sinlge_value);
00120
00126 YCPMap getObjectAttributes (string dn);
00127
00131 YCPBoolean deleteSubTree (string dn);
00132
00139 YCPBoolean moveWithSubtree (string dn, string new_dn, string parent_dn);
00140
00147 YCPBoolean copyOneEntry (string dn, string new_dn);
00148
00152 void debug_exception (LDAPException e, string action);
00153
00157 void generate_attr_list (LDAPAttributeList* attrs, YCPMap map);
00158
00163 void generate_mod_list (LDAPModList* modlist, YCPMap map, YCPValue attrs);
00164
00165 public:
00169 LdapAgent();
00170
00174 virtual ~LdapAgent();
00175
00181 virtual YCPValue Read ( const YCPPath &path,
00182 const YCPValue& arg = YCPNull(),
00183 const YCPValue& opt = YCPNull());
00184
00188 virtual YCPBoolean Write(const YCPPath &path,
00189 const YCPValue& arg,
00190 const YCPValue& arg2 = YCPNull());
00191
00195 virtual YCPValue Execute(const YCPPath &path,
00196 const YCPValue& arg = YCPNull(),
00197 const YCPValue& arg2 = YCPNull());
00198
00202 virtual YCPList Dir(const YCPPath& path);
00203
00207 virtual YCPValue otherCommand(const YCPTerm& term);
00208 };
00209
00210 #endif