/* Common includes */ #include "ldapconf.h" #include "ldapconf.m" #include "loghandler.h" #include #include #include #include #include #include "fields.h" class LDAPPROFILE; class LDAPOBJECT; class LDAPDB; /* Configuration */ extern const char *module_version; #define ATTR_VAL_MAX 1024 // Max length of attribute value #define ATTR_NAME_MAX 128 // Max length of attribute name #define COMMAND_MAX 256 // Max length of command line // Uncomment this to compile with internal debug support #define DEBUG // Uncomment this to compile with exprimental code (not used) //#define DEVEL /* Conditional */ // Disable debug code if DEBUG is undefined #ifdef DEBUG # define D(a) a; #else # define D(a) {} #endif /* Declarations */ extern const char PAM_SERVICES[]; extern const char PAM_MODULES[]; extern const char OPENLDAP_DATA_DIR[]; extern const char OPENLDAP_CONF_DIR[]; extern const char LDAPCONF_CONF_DIR[]; extern const char DBCONF_DIR[]; extern const char DBBIND_DIR[]; extern const char DBFORM_DIR[]; extern const char PROFILE_DIR[]; extern const char DBCONF_SUFFIX[]; extern const char subsys_ldap[]; // Helpfiles extern HELP_FILE help_index; extern HELP_FILE help_ldap; extern HELP_FILE help_ldapuser; extern HELP_FILE help_ldapclient; extern HELP_FILE help_ldapsystem; extern HELP_FILE help_formclient; extern HELP_FILE help_groupadmin; extern HELP_FILE help_setup; // Linuxconf privilege support (not used yet) extern PRIVILEGE p_ldap_admin; extern PRIVILEGE p_ldap_user; extern LINUXCONF_SUBSYS sub_ldap; // Configuration files used by ldapconf extern CONFIG_FILE f_slapd_conf; extern CONFIG_FILE f_ldap_conf; extern CONFIG_FILE f_ldap_sec; extern CONFIG_FILE f_nss_conf; extern CONFIG_FILE f_ldapconf; // Ldapconf module options extern char mode_ldap_system; extern char mode_ldap_client; extern char mode_ldap_server; extern char mode_ldap_profile; extern char mode_ldap_devel; extern int mode_ldap_debug; extern char mode_ldap_directory; extern char mode_ldap_userinfo; extern char mode_ldap_pwsync; extern char mode_ldap_useraccount; extern char mode_ldap_formclient; extern char mode_ldap_wwwclient; extern SSTRING mode_ldap_protocol; extern SSTRING mode_openldap_version; extern SSTRING mode_openldap_params; extern SSTRING mode_slapd_user; extern SSTRING mode_slapd_group; extern SSTRING mode_logfile; extern int mode_loglevel; extern char mode_posix_accounts; class TB_SSTRINGS: public ARRAY{ /*~PROTOBEG~ TB_SSTRINGS */ public: SSTRINGS *getitem (int no)const; /*~PROTOEND~ TB_SSTRINGS */ }; /* Class declarations */ class LDAPPROFILE: public ARRAY_OBJ { public: SSTRING host; SSTRING port; SSTRING dn; SSTRING pw; SSTRING base; SSTRING scope; SSTRING filter; SSTRING attr; SSTRING db_type; SSTRING db_dir; SSTRING db_replog; bool usesasl; int protocol; /*~PROTOBEG~ LDAPPROFILE */ public: LDAPPROFILE (void); void default_dialog (void); /*~PROTOEND~ LDAPPROFILE */ }; class LDAPDB: public ARRAY_OBJ { public: LDAPPROFILE bind; SSTRING name; /* DB nickname */ SSTRING database; /* Database type */ SSTRING directory; /* Data directory */ SSTRING replogfile; /* Replication log */ SSTRING updatedn; SSTRING replica; SSTRING lastmod; SSTRING readonly; SSTRINGS access_list; SSTRINGS attribute_list; SSTRINGS objectclass_list; SSTRINGS index_list; SSTRING defaultaccess; SSTRING loglevel; SSTRING schemacheck; SSTRING referral; /*~PROTOBEG~ LDAPDB */ public: LDAPDB (const char *dbname); LDAPDB (void); void config (const char *dbname); int create (void); int export_ldif (const char *profile_name); int export_ldif (void); int import_ldif (void); int init (const char *dbname); void menu (void); int read (const char *dbname); /*~PROTOEND~ LDAPDB */ }; class LDAPOBJECT: public ARRAY_OBJ { public: LDAPPROFILE bind; CONFDB *form; CONFDB *c_profile; SSTRING profile; SSTRING bindname; SSTRING formname; SSTRING dn_prefix; SSTRING group_prefix; SSTRING primary_key; SSTRING crypt_hash; SSTRING dn; SSTRING search_base; SSTRING scope; SSTRING filter; SSTRING attr; SSTRING command_line; SSTRINGS atlist; SSTRINGS oclist; SSTRING classes; // ObjectClass to add when creating a record char ldif_format; SSTRING ldapconf_entry; // Temp file to create ldif transactions int last_uid; // Record the last free uid number in use, so get_free_gid may copy it, may also be a hint for finding the next. /*~PROTOBEG~ LDAPOBJECT */ public: LDAPOBJECT (const char *profile_name); LDAPOBJECT (void); int add (void); void addclasses (void); int at_add (const char *name, const char *val); int at_add (const char *name, int val); int at_del (const char *name); const char *at_get (const char *name); const char *at_get (const char *name, int k); int at_getall (const char *name, SSTRINGS&lst); const char *at_getname (int num); const char *at_getval (int num); int at_list (SSTRINGS&lst); int at_set (const char *name, const char *val); int at_set (const char *name, int val); int command (const char *command, SSTRINGS&resmsg); int del (void); int dn_set (const char *val); char exist (const char *dn); int export_confdb (CONFDB&c_data); int export_ldif (const char *path); int export_ldif (const char *path, bool append); int get_free_gid (void); int get_free_uid (void); const char *gettmpfile (void)const; int import_confdb (const CONFDB&c_data, bool reset); int import_keys (const SSTRING_KEYS&c_data, bool reset); void init (void); int ldif_splitline (const char *ldif, SSTRING&name, SSTRING&val); int load_profile (const char *profile_name); int locate (const char *key, SSTRINGS&lst); SSTRING *locateassign (const char *key); SSTRING *locateassign (const char *key, int k); int modify (void); int oc_add (const SSTRING&val); int oc_add (const char *val); int oc_del (const char *name); int oc_exist (const char *name); const char *oc_getval (int num); int oc_list (SSTRINGS&lst); int reset (void); int reset_data (void); int search (void); int search_list (SSTRINGS&lst); int search_list_val (SSTRINGS&lst, const char *key); int search_list_vals (SSTRINGS&lst, const char *key, const char *at_name[]); int search_list_vals (TB_SSTRINGS&lst, const char *key, const char *at_name[]); int set_password (const char *username, const char *password); ~LDAPOBJECT (void); /*~PROTOEND~ LDAPOBJECT */ };