00001
00002 00003 00004 00005 00006 00007 00008 00009 00010 00011
00012 00013 00014 00015 00016 00017
00018 #pragma implementation
00019 #include <unistd.h>
00020 #include <string.h>
00021 #include <confdb.h>
00022 #include "ldapconf_defs.h"
00023
00024 PUBLIC LDAPDB::LDAPDB ()
00025 {
00026
00027 }
00028
00029 PUBLIC LDAPDB::LDAPDB (const char *dbname)
00030 {
00031 name.setfrom (dbname);
00032 }
00033
00034 PUBLIC int LDAPDB::init(const char *dbname)
00035 {
00036 int ret = 0;
00037
00038
00039 char buf[256];
00040 gethostname(buf,sizeof(buf));
00041 dns2dc(buf,sizeof(buf),1);
00042
00043
00044 bind.base.setfrom(buf);
00045 bind.dn.setfromf ("cn=manager,%s",buf);
00046 bind.pw.setfrom ("secret");
00047 database.setfrom ("ldbm");
00048 directory.setfromf ("%s/%s",OPENLDAP_DATA_DIR,dbname);
00049 replogfile.setfromf ("%s/%s/%s.log",OPENLDAP_DATA_DIR,dbname,dbname);
00050 updatedn.setfrom ("");
00051 replica.setfrom ("");
00052 lastmod.setfrom ("off");
00053 readonly.setfrom ("off");
00054 schemacheck.setfrom("on");
00055 defaultaccess.setfrom("none");
00056 loglevel.setfrom("0");
00057
00058
00059 file_mkdirp(directory.get(),
00060 mode_slapd_user.get(),
00061 mode_slapd_group.get(),
00062 0700);
00063 return ret;
00064 }
00065
00066 PUBLIC int LDAPDB::read(const char *dbname)
00067 {
00068 int ret = 0;
00069 VIEWITEMS v_db_conf;
00070 char path[PATH_MAX] = "";
00071 sprintf (path,"%s/%s%s",DBCONF_DIR,dbname,DBCONF_SUFFIX);
00072 CONFIG_FILE f_db_conf (path,
00073 help_ldap,
00074 CONFIGF_OPTIONNAL|CONFIGF_MANAGED,
00075 mode_slapd_user.get(),
00076 mode_slapd_group.get(),
00077 0400,
00078 subsys_ldap);
00079
00080 name.setfrom (dbname);
00081
00082 v_db_conf.read (f_db_conf);
00083 bind.base.setfrom (get_keyval(v_db_conf,"suffix"));
00084 bind.dn.setfrom (get_keyval(v_db_conf,"rootdn"));
00085 bind.pw.setfrom (get_keyval(v_db_conf,"rootpw"));
00086 database.setfrom (get_keyval(v_db_conf,"database"));
00087 directory.setfrom (get_keyval(v_db_conf,"directory"));
00088 replogfile.setfrom (get_keyval(v_db_conf,"replogfile"));
00089 updatedn.setfrom (get_keyval(v_db_conf,"updatedn"));
00090 replica.setfrom (get_keyval(v_db_conf,"replica"));
00091 lastmod.setfrom (get_keyval(v_db_conf,"lastmod"));
00092 readonly.setfrom (get_keyval(v_db_conf,"readonly"));
00093 schemacheck.setfrom (get_keyval(v_db_conf,"schemacheck"));
00094 loglevel.setfrom (get_keyval(v_db_conf,"loglevel"));
00095 defaultaccess.setfrom (get_keyval(v_db_conf,"defaultaccess"));
00096 referral.setfrom (get_keyval(v_db_conf,"referral"));
00097
00098 return ret;
00099 }
00100
00101 00102 00103
00104 PUBLIC int LDAPDB::export_ldif()
00105 {
00106 char include_indexnumber=true;
00107 int ret=0;
00108 char dbfile[PATH_MAX] = "";
00109 sprintf (dbfile,"%s/id2entry.dbb",directory.get());
00110 char exportfile [PATH_MAX] = "";
00111 sprintf (exportfile,"/tmp/%s.ldif",name.get());
00112 SSTRING filename(exportfile);
00113 int nof;
00114 DIALOG dia;
00115 dia.newf_str (MSG_U(F_EXPORT_LDIF_FILE,"LDIF Filename"),exportfile,40);
00116 dia.newf_chk ("",include_indexnumber,"Include index number ");
00117 while (1){
00118 MENU_STATUS code = dia.edit (MSG_U(T_EXPORT_LDIF,"LDIF Export")
00119 ,MSG_U(I_EXPORT_LDIF
00120 ,"This will export all entries from this database\n"
00121 "into a LDIF file.\n"
00122 "You must stop the server before you export using this dialog.")
00123 ,help_ldap
00124 ,nof);
00125 if (code == MENU_CANCEL || code == MENU_ESCAPE){
00126 break;
00127 }
00128 else if (code == MENU_ACCEPT){
00129 char arg[1000] = "";
00130 if (!include_indexnumber) {
00131 sprintf (arg,"-n");
00132 }
00133 sprintf (arg,"%s > %s",dbfile,exportfile);
00134 sys_command_title("LDIF Export","ldbmcat",arg);
00135 break;
00136 }
00137 }
00138 return ret;
00139 }
00140
00141 00142 00143
00144 PUBLIC int LDAPDB::export_ldif(const char *profile_name)
00145 {
00146 int ret=0;
00147 char path [PATH_MAX];
00148 sprintf(path,"/tmp/%s.ldif",profile_name);
00149 int nof;
00150
00151 SSTRING export_file(path);
00152 SSTRING export_filter("objectclass=*");
00153 SSTRING export_attributes("");
00154
00155 SSTRINGS data;
00156 LDAPOBJECT ldap;
00157
00158 DIALOG dia;
00159
00160 dia.newf_str (MSG_U(F_EXPORT_FILE,"Filename"),export_file,40);
00161 dia.newf_str (MSG_U(F_EXPORT_FILTER,"Search filter"),export_filter);
00162 dia.newf_str (MSG_U(F_EXPORT_ATTR,"Attribute list"),export_attributes);
00163
00164 while (1){
00165 MENU_STATUS code = dia.edit (MSG_R(T_EXPORT_LDIF),
00166 MSG_U(I_EXPORT_LDIF_ONLINE,
00167 "Use this dialog to export data from the directory into the specified file.\n"
00168 "The default search filter will include all entries.\n"
00169 "The default (empty) attribute list will include all attributes."
00170 ),
00171 help_ldap,
00172 nof);
00173 if (code == MENU_CANCEL || code == MENU_ESCAPE){
00174 break;
00175 }
00176 else if (code == MENU_ACCEPT){
00177
00178 ldap.load_profile(profile_name);
00179 ldap.filter.setfrom(export_filter.get());
00180 ldap.command_line = export_attributes;
00181
00182 ldap.command("ldapsearch",data);
00183
00184 int n = data.getnb();
00185
00186
00187 FILE *fout = fopen (export_file.get(),"w");
00188 if (fout != NULL){
00189 for (int i=0; i<n; i++){
00190 fprintf(fout,"%s",data.getitem(i)->get());
00191 }
00192 xconf_notice("Wrote %i lines of LDIF data to file",n);
00193 }
00194 else {
00195 xconf_error("File error");
00196 }
00197 break;
00198 }
00199 }
00200 return ret;
00201 }
00202
00203 00204 00205
00206 PUBLIC int LDAPDB::create()
00207 {
00208 int ret=0;
00209 char domain[PATH_MAX];
00210 char conffile[PATH_MAX];
00211 SSTRINGS dc_lst;
00212 LDAPOBJECT ldap;
00213 char profile_name[PATH_MAX];
00214
00215
00216 char add_suffixobject = true;
00217 char add_peopleobject = true;
00218 char add_groupobject = true;
00219 char gen_manager_profile = true;
00220
00221 sprintf (conffile,"%s/%s%s",DBCONF_DIR,name.get(),DBCONF_SUFFIX);
00222
00223
00224 strcpy(domain,bind.base.get());
00225 dc2list(domain,dc_lst);
00226 dc2dns(domain,sizeof(domain));
00227
00228 int nof;
00229
00230 DIALOG dia;
00231
00232 dia.newf_chk (MSG_U(F_ADD_DC_DOMAIN,"Add domain DC objects"),add_suffixobject,"Domain");
00233 dia.newf_chk (MSG_U(F_ADD_OU_PEOPLE,"Add people OU object"),add_peopleobject,"People");
00234 dia.newf_chk (MSG_U(F_ADD_OU_GROUP,"Add group OU object"),add_groupobject,"Group");
00235 dia.newf_chk (MSG_U(F_GEN_MANAGER_PROFILE,"Generate manager profile"),gen_manager_profile,"Manager");
00236
00237 while (1){
00238 MENU_STATUS code = dia.edit (MSG_U(T_CREATE,"Create")
00239 ,MSG_U(I_CREATE
00240 ,"This will init a new database.")
00241 ,help_ldap
00242 ,nof);
00243 if (code == MENU_CANCEL || code == MENU_ESCAPE){
00244 break;
00245 }
00246 else if (code == MENU_ACCEPT){
00247 char path[PATH_MAX];
00248 CONFIG_FILE *f_profile;
00249 CONFDB *c_profile;
00250
00251 if (gen_manager_profile==true) {
00252
00253 sprintf(profile_name,"%s-manager",name.get());
00254
00255
00256 sprintf(path,"%s/%s",DBBIND_DIR,profile_name);
00257 f_profile = new CONFIG_FILE (path,
00258 help_ldap,
00259 CONFIGF_MANAGED|CONFIGF_OPTIONAL,
00260 "root","root",0600);
00261 c_profile = new CONFDB(*f_profile);
00262
00263 c_profile->replace("ldap","base",bind.base.get());
00264 c_profile->replace("ldap","host","localhost");
00265 c_profile->replace("ldap","binddn",bind.dn.get());
00266 c_profile->replace("ldap","bindpw",bind.pw.get());
00267
00268 c_profile->save();
00269
00270 delete c_profile;
00271 delete f_profile;
00272
00273
00274 sprintf(path,"%s/%s",PROFILE_DIR,name.get());
00275 f_profile = new CONFIG_FILE (path,
00276 help_ldap,
00277 CONFIGF_MANAGED|CONFIGF_OPTIONAL,
00278 "root","root",0600);
00279 c_profile = new CONFDB(*f_profile);
00280
00281 c_profile->replace("profile","bind",profile_name);
00282
00283 char buf[100];
00284 sprintf(buf,"Manager profile for directory %s",name.get());
00285 c_profile->replace("profile","comment",buf);
00286
00287 c_profile->save();
00288
00289 delete c_profile;
00290 delete f_profile;
00291 }
00292 else {
00293
00294
00295 sprintf(profile_name,"%s","root-manager");
00296 }
00297
00298 SSTRING line;
00299 if (add_suffixobject==true) {
00300 ldap.load_profile(name.get());
00301
00302 ldap.dn.setfromf("dn: %s",bind.base.get());
00303 ldap.at_add("dc",dc_lst.getitem(0)->get());
00304 ldap.oc_add("top");
00305 ldap.oc_add("domain");
00306 ldap.oc_add("domainRelatedObject");
00307 ldap.at_add("associatedDomain",domain);
00308
00309 ldap.add();
00310 }
00311 if (add_peopleobject==true) {
00312 ldap.load_profile(name.get());
00313 ldap.reset_data();
00314
00315 ldap.dn.setfromf("dn: ou=People,%s",bind.base.get());
00316 ldap.at_add("ou","People");
00317 ldap.oc_add("top");
00318 ldap.oc_add("organizationalUnit");
00319 ldap.oc_add("domainRelatedObject");
00320 ldap.at_add("associatedDomain",domain);
00321
00322 ldap.add();
00323 }
00324 if (add_groupobject==true) {
00325 ldap.load_profile(name.get());
00326 ldap.reset_data();
00327
00328 ldap.dn.setfromf("dn: ou=Group,%s",bind.base.get());
00329 ldap.at_add("ou","Group");
00330 ldap.oc_add("top");
00331 ldap.oc_add("organizationalUnit");
00332 ldap.oc_add("domainRelatedObject");
00333 ldap.at_add("associatedDomain",domain);
00334
00335 ldap.add();
00336 }
00337
00338 00339 00340 00341 00342 00343 00344 00345 00346 00347 00348 00349 00350 00351 00352 00353 00354 00355 00356 00357 00358 00359 00360 00361 00362 00363 00364 00365 00366 00367 00368
00369
00370 00371 00372 00373 00374 00375 00376 00377 00378 00379 00380 00381 00382
00383 break;
00384 }
00385 }
00386 return ret;
00387 }
00388
00389 00390 00391 00392 00393 00394
00395 PUBLIC int LDAPDB::import_ldif()
00396 {
00397 int ret=0;
00398 char add_suffix=true;
00399 char add_suffixobject=true;
00400 char conffile[PATH_MAX] = "";
00401 sprintf (conffile,"%s/%s%s",DBCONF_DIR,name.get(),DBCONF_SUFFIX);
00402 char importfile [PATH_MAX] = "";
00403 sprintf (importfile,"/tmp/%s.ldif",name.get());
00404 SSTRING filename(importfile);
00405 SSTRING profile;
00406 int nof;
00407
00408 LDAPOBJECT ldap;
00409
00410 profile.setfrom(name.get());
00411
00412 DIALOG dia;
00413
00414 dia.newf_str (MSG_U(F_IMPORT_LDIF_FILE,"LDIF Filename"),importfile,40);
00415 dia.newf_str (MSG_U(F_IMPORT_LDIF_PROFILE,"Use directory profile"),profile,40);
00416 dia.newf_chk ("Add domainsuffix to DN attributes",add_suffix,"DN Suffix ");
00417 dia.newf_chk ("Add domainobject to database",add_suffixobject,"DB Suffix");
00418 while (1){
00419 MENU_STATUS code = dia.edit (MSG_U(T_IMPORT_LDIF,"LDIF Import")
00420 ,MSG_U(I_IMPORT_LDIF
00421 ,"Import entries from LDIF file into directory")
00422 ,help_ldap
00423 ,nof);
00424 if (code == MENU_CANCEL || code == MENU_ESCAPE){
00425 break;
00426 }
00427 else if (code == MENU_ACCEPT){
00428
00429 ldap.load_profile(profile.get());
00430
00431
00432 FILE *fin = fopen(importfile,"r");
00433 FILE *fout = fopen(ldap.ldapconf_entry,"w");
00434 if ((fin != NULL)) {
00435 SSTRING line;
00436 char buf[1000];
00437 int n=0;
00438
00439 if (add_suffixobject==true) {
00440
00441 fprintf (fout,"dn: %s\n",bind.base.get());
00442 fprintf (fout,"%s\n",bind.base.get());
00443 fprintf (fout,"objectclass: top\n");
00444 fprintf (fout,"objectclass: domain\n");
00445 fprintf (fout,"\n");
00446 }
00447
00448 while (fgets(buf,sizeof(buf)-1,fin)!=NULL){
00449 strip_end(buf);
00450 line.setfrom(buf);
00451 if (line.strstr("dn:")){
00452 n++;
00453 if (add_suffixobject==true){
00454 line.appendf(",%s",bind.base.get());
00455 }
00456 D(debugf(5,"Adding object count=%i %s",n,line.get()));
00457 }
00458 fprintf (fout,"%s\n",line.get());
00459 }
00460 fclose (fin);
00461 fclose (fout);
00462
00463
00464
00465 ldap.command_line.setfrom(" -a");
00466 ldap.command_line.appendf(" -f %s",ldap.ldapconf_entry);
00467 SSTRINGS resmsg;
00468 ret = ldap.command ("ldapmodify",resmsg);
00469 unlink(ldap.ldapconf_entry);
00470 logf(LOG_NORMAL,"Importing LDIF file %s using profile %s",importfile,profile.get());
00471 }
00472 break;
00473 }
00474 }
00475 return ret;
00476
00477 00478 00479 00480 00481 00482 00483 00484 00485 00486 00487 00488 00489 00490 00491 00492 00493 00494 00495 00496 00497 00498 00499 00500 00501 00502 00503 00504 00505 00506 00507 00508 00509 00510 00511 00512 00513 00514 00515 00516 00517 00518 00519 00520
00521
00522 }
00523
00524 00525 00526
00527
00528 PUBLIC void LDAPDB::config(const char *dbname){
00529 CONFIG_FILE f_slapd_conf ("slapd.conf",
00530 help_ldap,
00531 CONFIGF_OPTIONNAL|CONFIGF_MANAGED,
00532 mode_slapd_user.get(),
00533 mode_slapd_group.get(),
00534 0400,
00535 subsys_ldap);
00536 VIEWITEMS v_db_conf;
00537 VIEWITEMS v_slapd_conf;
00538
00539 char was_enabled = false;
00540 char enable_database = true;
00541 char acl_selfwrite = true;
00542 char index_nss = true;
00543 char path[PATH_MAX] = "";
00544
00545
00546 sprintf (path,"%s/%s%s",DBCONF_DIR,dbname,DBCONF_SUFFIX);
00547
00548
00549 VIEWITEMS inc_items;
00550 VIEWITEM *inc_item=NULL;
00551 v_slapd_conf.read (f_slapd_conf);
00552 int n = v_slapd_conf.locate("include",inc_items);
00553 for (int i=0; i<n; i++){
00554 inc_item = inc_items.getitem(i);
00555 if (inc_item->line.strstr(path)!=0) {
00556 enable_database = true;
00557 was_enabled = true;
00558 break;
00559 }
00560 }
00561
00562
00563 SSTRING filename(path);
00564 DIALOG dia;
00565
00566 dia.newf_title (MSG_U(I_GENERAL_PARAM,"General"),1,"","");
00567 dia.newf_chk (MSG_U(F_DB_ENABLE,"Enable database"),enable_database," ");
00568 dia.newf_str (MSG_U(F_DB_PROFILE,"Config file"),filename);
00569 FIELD_COMBO *dblist = dia.newf_combo(MSG_U(F_SLAPD_DATABASE,"Database type"),database);
00570 dblist->addopt ("ldbm");
00571 dblist->addopt ("shell");
00572 dblist->addopt ("passwd");
00573 dia.newf_str (MSG_U(F_DB_DIRECTORY,"LDBM directory path"),directory);
00574 FIELD_COMBO *readonly_key = dia.newf_combo (MSG_U(F_DB_READONLY,"Readonly"),readonly);
00575 readonly_key->addopt ("on");
00576 readonly_key->addopt ("off");
00577
00578 FIELD_COMBO *schema = dia.newf_combo(MSG_U(F_DB_SCHEMACHECK,"Schemacheck"),schemacheck);
00579 schema->addopt ("on");
00580 schema->addopt ("off");
00581 dia.newf_str (MSG_U(F_DB_LOGLEVEL,"Loglevel"),loglevel);
00582 FIELD_COMBO *accesslist = dia.newf_combo(MSG_U(F_DB_DEFAULTACCESS,"Default access"),defaultaccess);
00583 accesslist->addopt ("none");
00584 accesslist->addopt ("compare");
00585 accesslist->addopt ("search");
00586 accesslist->addopt ("read");
00587 accesslist->addopt ("write");
00588
00589 dia.newf_str (MSG_U(F_DB_REFERRAL,"Referral"),referral);
00590
00591 dia.newf_title (MSG_U(I_MASTER_DATABASE,"Root"),1,"","");
00592 dia.newf_str (MSG_R(F_API_BASE),bind.base);
00593 dia.newf_str (MSG_R(F_API_DN),bind.dn);
00594 dia.newf_str (MSG_R(F_API_PW),bind.pw);
00595
00596 dia.newf_title (MSG_U(I_MASTER_PARAM,"Master"),1,"","");
00597 FIELD_COMBO *lastmod_key= dia.newf_combo (MSG_U(F_DB_LASTMOD,"Lastmod recording"),lastmod);
00598 lastmod_key->addopt ("on");
00599 lastmod_key->addopt ("off");
00600 dia.newf_str (MSG_U(F_DB_REPLOG,"Replicaton log"),replogfile);
00601 dia.newf_str (MSG_U(F_DB_REPLICA,"Replica host"),replica);
00602
00603 dia.newf_title (MSG_U(I_SLAVE_PARAM,"Slave"),1,"","");
00604 dia.newf_str (MSG_U(F_DB_UPDATEDN,"Update DN"),updatedn);
00605
00606 dia.newf_title (MSG_U(I_ACL_PARAM,"ACL"),1,"","");
00607 dia.newf_info ("","Simple ACL config only");
00608 dia.newf_chk (MSG_U(F_ACL_SELFWRITE,"Add ACL to allow writing SELF object"),acl_selfwrite,"");
00609
00610 dia.newf_title (MSG_U(I_ACCESS_PARAM,"Attributes"),1,"","");
00611 dia.newf_info ("","Not done");
00612
00613 dia.newf_title (MSG_U(I_INDEXES_PARAM,"Indexes"),1,"","");
00614 dia.newf_info ("","Simple index config only");
00615 dia.newf_chk (MSG_U(F_INDEX_NSS,"Add indexes to improve NSS performance"),index_nss,"");
00616
00617 dia.setbutinfo (MENU_USR1,MSG_U(B_EXPORT,"Export")
00618 ,MSG_U(X_EXPORT,"Export"));
00619 dia.setbutinfo (MENU_USR2,MSG_U(B_IMPORT,"Import")
00620 ,MSG_U(X_IMPORT,"Import"));
00621
00622 int nof = 0;
00623 while (1){
00624 MENU_STATUS code = dia.edit (MSG_U(T_DATABASE_MENU,"LDAP database")
00625 ,MSG_U(I_DATABASE_MENU
00626 ,"Here you may configure a LDAP directory.\n"
00627 "Currently ldapconf will save directory setting in individual files,\n"
00628 "and then include this files in the main slapd.conf file.\n"
00629 "You may still have database settings in the main file,\n"
00630 "but ldapconf will not operate on those.")
00631 ,help_ldap
00632 ,nof
00633 ,MENUBUT_ACCEPT|MENUBUT_CANCEL);
00634
00635 if (code == MENU_CANCEL || code == MENU_ESCAPE){
00636 break;
00637 }
00638 else if (code == MENU_USR1){
00639 export_ldif();
00640 }
00641 else if (code == MENU_USR2){
00642 import_ldif();
00643 }
00644 else if (code == MENU_ACCEPT){
00645 set_keyval(v_db_conf,"database",database.get());
00646 set_keyval(v_db_conf,"suffix",bind.base.get());
00647 set_keyval(v_db_conf,"rootdn",bind.dn.get());
00648 set_keyval(v_db_conf,"rootpw",bind.pw.get());
00649 set_keyval(v_db_conf,"directory",directory.get());
00650 set_keyval(v_db_conf,"readonly",readonly.get());
00651 set_keyval(v_db_conf,"lastmod",lastmod.get());
00652 set_keyval(v_db_conf,"replogfile",replogfile.get());
00653 set_keyval(v_db_conf,"replica",replica.get());
00654 set_keyval(v_db_conf,"updatedn",updatedn.get());
00655 set_keyval(v_db_conf,"schemacheck",schemacheck.get());
00656 set_keyval(v_db_conf,"loglevel",loglevel.get());
00657 set_keyval(v_db_conf,"defaultaccess",defaultaccess.get());
00658 set_keyval(v_db_conf,"referral",referral.get());
00659
00660 if (acl_selfwrite){
00661 v_db_conf.add(new VIEWITEM("access to attr=userpassword by self write by * compare"));
00662 v_db_conf.add(new VIEWITEM("access to * by self write"));
00663 }
00664 if (index_nss) {
00665 v_db_conf.add(new VIEWITEM("index objectclass,uid,uidNumber,gidNumber\teq"));
00666 v_db_conf.add(new VIEWITEM("index cn,mail,surname,givenname\teq,subinitial"));
00667 }
00668
00669 CONFIG_FILE f_db_conf_save (path,
00670 help_ldap,
00671 CONFIGF_OPTIONNAL|CONFIGF_MANAGED,
00672 mode_slapd_user.get(),
00673 mode_slapd_group.get(),
00674 0400,
00675 subsys_ldap);
00676 v_db_conf.write (f_db_conf_save,&p_ldap_admin);
00677 if (enable_database && !was_enabled) {
00678 char buf[1000];
00679 VIEWITEM *it;
00680 sprintf(buf,"%s %s","include",path);
00681 it = new VIEWITEM(buf);
00682 v_slapd_conf.add(it);
00683 logf(LOG_NOTICE,"Enabling database profile %s",path);
00684 }
00685 else if (was_enabled && !enable_database) {
00686 inc_item->line.setfrom("");
00687 logf(LOG_NOTICE,"Disabling database profile %s",path);
00688 }
00689
00690 v_slapd_conf.write(f_slapd_conf,&p_ldap_admin);
00691
00692
00693 if (xconf_yesno(MSG_U(T_SERVER_RESTART_OK,"Confirm server restart"),
00694 MSG_U(I_SERVER_RESTART_OK,
00695 "To activate the changes, the server must be restarted.\n"
00696 "But be aware that if anything is wrong in the new configuration\n"
00697 "the server may refuse to start. This may be critical if the server\n"
00698 "is publishing production critical directory data to clients.\n"
00699 "Do you want to restart the server now?\n"
00700 ),
00701 help_ldap) == MENU_YES){
00702 sys_command_title ("Server restart","slapd.init","restart");
00703 }
00704 break;
00705 }
00706 }
00707 }
00708
00709 00710 00711
00712 PUBLIC void LDAPDB::menu()
00713 {
00714 const char *config_key = MSG_U(M_DB_CONFIG,"Configure directory");
00715 const char *create_key = MSG_U(M_DB_CREATE,"Init a new empty directory");
00716 const char *export_key = MSG_U(M_DB_EXPORT,"Export from directory to LDIF file");
00717 const char *import_key = MSG_U(M_DB_IMPORT,"Import from LDIF file to directory");
00718 const char *migrate_key = MSG_U(M_DB_MIGRATE,"Migrate from system to directory");
00719
00720 DIALOG_MENU dia;
00721 dia.new_menuinfo("Directory name",name.get());
00722 dia.new_menuitem("Config",config_key);
00723 dia.new_menuitem("Init",create_key);
00724 dia.new_menuitem("Export LDIF",export_key);
00725 dia.new_menuitem("Import LDIF",import_key);
00726 dia.new_menuitem("Import users",migrate_key);
00727
00728 int nof = 0;
00729 while (1){
00730 MENU_STATUS code = dia.editmenu (MSG_U(T_DB_MENU,"Directory menu")
00731 ,MSG_U(I_DB_MENU,"Select operation to perform on this directory")
00732 ,help_ldap
00733 ,nof,0);
00734 const char *key = dia.getmenustr(nof);
00735
00736 if (code == MENU_ESCAPE || code == MENU_QUIT){
00737 break;
00738 }else{
00739 if (key == config_key){
00740 config(name.get());
00741 }else if (key == export_key){
00742 export_ldif(name.get());
00743 }else if (key == import_key){
00744 import_ldif();
00745 }else if (key == migrate_key){
00746 ldap_migrate_users(name.get());
00747 }else if (key == create_key){
00748 create();
00749 }
00750 }
00751 }
00752 }
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774