yast2-ldap
LdapAgent.h
Go to the documentation of this file.
00001 /* ------------------------------------------------------------------------------
00002  * Copyright (c) 2006-2012 Novell, Inc. All Rights Reserved.
00003  *
00004  *
00005  * This program is free software; you can redistribute it and/or modify it under
00006  * the terms of version 2 of the GNU General Public License as published by the
00007  * Free Software Foundation.
00008  *
00009  * This program is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License along with
00014  * this program; if not, contact Novell, Inc.
00015  *
00016  * To contact Novell about this file by physical or electronic mail, you may find
00017  * current contact information at www.novell.com.
00018  * ------------------------------------------------------------------------------
00019  */
00020 
00021 /* LdapAgent.h
00022  *
00023  * Ldap agent implementation
00024  *
00025  * Authors: Jiri Suchomel <jsuchome@suse.cz>
00026  *
00027  * $Id$
00028  */
00029 
00030 #ifndef _LdapAgent_h
00031 #define _LdapAgent_h
00032 
00033 #include <Y2.h>
00034 #include <scr/SCRAgent.h>
00035 
00036 #include <LDAPConnection.h>
00037 #include <LDAPException.h>
00038 #include <LDAPAttributeList.h>
00039 #include <LDAPAttribute.h>
00040 
00041 #include <LDAPSchema.h>
00042 
00043 #define DEFAULT_PORT 389
00044 #define ANSWER  42
00045 #define MAX_LENGTH_ID 5
00046 
00050 class LdapAgent : public SCRAgent
00051 {
00052 private:
00056     int port;
00057     string hostname;
00058     string bind_dn;
00059     string bind_pw;
00060     string ldap_error;
00061     string server_error;
00062     bool tls_error;
00063 
00064     int ldap_error_code;
00065     bool ldap_initialized;
00066 
00067     string userpw_hash;
00068 
00069     LDAPConnection *ldap;
00070     LDAPConstraints *cons;
00071     LDAPSchema *schema;
00072 
00073     YCPMap  users,
00074             users_by_name,
00075             users_by_uidnumber,
00076             usernames,
00077             userdns,
00078             uids,
00079             homes,
00080             user_items,
00081             groups,
00082             groups_by_name,
00083             groups_by_gidnumber,
00084             groupnames,
00085             gids,
00086             group_items;
00087 
00092     string getValue ( const YCPMap map, const string key);
00093 
00100     int getIntValue ( const YCPMap map, const string key, int deflt);
00101     
00102     bool getBoolValue (const YCPMap map, const string key);
00103 
00104     YCPList getListValue (const YCPMap map, const string key);
00105 
00109     StringList ycplist2stringlist (YCPList l);
00110     
00114     YCPList stringlist2ycplist (StringList sl);
00115 
00119     YCPList stringlist2ycplist_low (StringList sl);
00120 
00126     YCPMap getGroupEntry (LDAPEntry *entry, string member_attribute);
00127 
00132     YCPMap getUserEntry (LDAPEntry *entry);
00133 
00139     YCPMap getSearchedEntry (LDAPEntry *entry, bool sinlge_value);
00140 
00146     YCPMap getObjectAttributes (string dn);
00147 
00151     YCPBoolean deleteSubTree (string dn);
00152 
00159     YCPBoolean moveWithSubtree (string dn, string new_dn, string parent_dn);
00160     
00167     YCPBoolean copyOneEntry (string dn, string new_dn);
00168  
00172     void debug_exception (LDAPException e, string action);
00173     
00177     void debug_referral (LDAPReferralException e, string action);
00178 
00182     void set_tls_options (YCPMap args, string tls);
00183 
00187     void generate_attr_list (LDAPAttributeList* attrs, YCPMap map);
00188 
00193     void generate_mod_list (LDAPModList* modlist, YCPMap map, YCPValue attrs);
00194 
00195 public:
00199     LdapAgent();
00200 
00204     virtual ~LdapAgent();
00205 
00211     virtual YCPValue Read ( const YCPPath &path,
00212                             const YCPValue& arg = YCPNull(),
00213                             const YCPValue& opt = YCPNull());
00214 
00218     virtual YCPBoolean Write(const YCPPath &path,
00219                            const YCPValue& arg,
00220                            const YCPValue& arg2 = YCPNull());
00221 
00225     virtual YCPValue Execute(const YCPPath &path,
00226                              const YCPValue& arg = YCPNull(),
00227                              const YCPValue& arg2 = YCPNull());
00228 
00232     virtual YCPList Dir(const YCPPath& path);
00233 
00237     virtual YCPValue otherCommand(const YCPTerm& term);
00238 };
00239 
00240 #endif /* _LdapAgent_h */

Generated on a sunny day for yast2-ldap by doxygen 1.7.6.1