LdapAgent.h

Go to the documentation of this file.
00001 /* LdapAgent.h
00002  *
00003  * Ldap agent implementation
00004  *
00005  * Authors: Jiri Suchomel <jsuchome@suse.cz>
00006  *
00007  * $Id: LdapAgent.h 35223 2007-01-11 12:09:21Z jsuchome $
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     bool tls_error;
00044 
00045     int ldap_error_code;
00046     bool ldap_initialized;
00047 
00048     string userpw_hash;
00049 
00050     LDAPConnection *ldap;
00051     LDAPConstraints *cons;
00052     LDAPSchema *schema;
00053 
00054     YCPMap  users,
00055             users_by_name,
00056             users_by_uidnumber,
00057             usernames,
00058             userdns,
00059             uids,
00060             homes,
00061             user_items,
00062             groups,
00063             groups_by_name,
00064             groups_by_gidnumber,
00065             groupnames,
00066             gids,
00067             group_items;
00068 
00073     string getValue ( const YCPMap map, const string key);
00074 
00081     int getIntValue ( const YCPMap map, const string key, int deflt);
00082     
00083     bool getBoolValue (const YCPMap map, const string key);
00084 
00085     YCPList getListValue (const YCPMap map, const string key);
00086 
00090     StringList ycplist2stringlist (YCPList l);
00091     
00095     YCPList stringlist2ycplist (StringList sl);
00096 
00100     YCPList stringlist2ycplist_low (StringList sl);
00101 
00107     YCPMap getGroupEntry (LDAPEntry *entry, string member_attribute);
00108 
00113     YCPMap getUserEntry (LDAPEntry *entry);
00114 
00120     YCPMap getSearchedEntry (LDAPEntry *entry, bool sinlge_value);
00121 
00127     YCPMap getObjectAttributes (string dn);
00128 
00132     YCPBoolean deleteSubTree (string dn);
00133 
00140     YCPBoolean moveWithSubtree (string dn, string new_dn, string parent_dn);
00141     
00148     YCPBoolean copyOneEntry (string dn, string new_dn);
00149  
00153     void debug_exception (LDAPException e, string action);
00154     
00158     void debug_referral (LDAPReferralException e, string action);
00159 
00163     void generate_attr_list (LDAPAttributeList* attrs, YCPMap map);
00164 
00169     void generate_mod_list (LDAPModList* modlist, YCPMap map, YCPValue attrs);
00170 
00171 public:
00175     LdapAgent();
00176 
00180     virtual ~LdapAgent();
00181 
00187     virtual YCPValue Read ( const YCPPath &path,
00188                             const YCPValue& arg = YCPNull(),
00189                             const YCPValue& opt = YCPNull());
00190 
00194     virtual YCPBoolean Write(const YCPPath &path,
00195                            const YCPValue& arg,
00196                            const YCPValue& arg2 = YCPNull());
00197 
00201     virtual YCPValue Execute(const YCPPath &path,
00202                              const YCPValue& arg = YCPNull(),
00203                              const YCPValue& arg2 = YCPNull());
00204 
00208     virtual YCPList Dir(const YCPPath& path);
00209 
00213     virtual YCPValue otherCommand(const YCPTerm& term);
00214 };
00215 
00216 #endif /* _LdapAgent_h */

Generated on Tue Sep 25 20:29:10 2007 for yast2-ldap by  doxygen 1.5.3