r13148: Fix bug: #3413
authorSimo Sorce <idra@samba.org>
Thu, 26 Jan 2006 00:14:25 +0000 (00:14 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:06:15 +0000 (11:06 -0500)
Check that ldap admin dn is defined in smb.conf before
setting the ldap password in secrets.tdb

Based on patch by William Jojo <jojowil@hvcc.edu>

Simo.
(This used to be commit c2c004a620ecbd895786dc6f16fb6a616f354a0a)

source3/utils/smbpasswd.c

index 7659bb2997a2ae8396a5d4fa0afa23f0948e8bb6..29189c5febd9cb27902b4d3c1d066548cc4b641a 100644 (file)
@@ -327,14 +327,20 @@ static int process_root(int local_flags)
        char *old_passwd = NULL;
 
        if (local_flags & LOCAL_SET_LDAP_ADMIN_PW) {
-               printf("Setting stored password for \"%s\" in secrets.tdb\n", 
-                       lp_ldap_admin_dn());
+               char *ldap_admin_dn = lp_ldap_admin_dn();
+               if ( ! *ldap_admin_dn ) {
+                       DEBUG(0,("ERROR: 'ldap admin dn' not defined! Please check your smb.conf\n"));
+                       goto done;
+               }
+
+               printf("Setting stored password for \"%s\" in secrets.tdb\n", ldap_admin_dn);
                if ( ! *ldap_secret ) {
                        new_passwd = prompt_for_new_password(stdin_passwd_get);
                        fstrcpy(ldap_secret, new_passwd);
                }
-               if (!store_ldap_admin_pw(ldap_secret))
+               if (!store_ldap_admin_pw(ldap_secret)) {
                        DEBUG(0,("ERROR: Failed to store the ldap admin password!\n"));
+               }
                goto done;
        }