summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorJean-François Micouleau <jfm@samba.org>2001-12-13 18:09:29 +0000
committerJean-François Micouleau <jfm@samba.org>2001-12-13 18:09:29 +0000
commit9f59fc64b8c1772b6a73d1649013d2187c298868 (patch)
treef6ebbb3e764fc618b88092477a0ac96078ef823a /source3/utils
parent037b40f01f8ec42250b33de08680d4f6a06eac64 (diff)
downloadsamba-9f59fc64b8c1772b6a73d1649013d2187c298868.tar.gz
samba-9f59fc64b8c1772b6a73d1649013d2187c298868.tar.bz2
samba-9f59fc64b8c1772b6a73d1649013d2187c298868.zip
update the ldap support code. it compiles.
Ignacio you can update your howto ;-) samsync: a small patch to try chaning challenges. J.F. (This used to be commit c99bc305599698f2291efbfe20024355cb2bcde0)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/smbpasswd.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c
index e076687c4f..7086fbff37 100644
--- a/source3/utils/smbpasswd.c
+++ b/source3/utils/smbpasswd.c
@@ -56,6 +56,9 @@ static void usage(void)
printf(" -e enable user\n");
printf(" -n set no password\n");
printf(" -m machine trust account\n");
+#ifdef WITH_LDAP_SAM
+ printf(" -w ldap admin password\n");
+#endif
exit(1);
}
@@ -170,6 +173,21 @@ static BOOL password_change(const char *remote_machine, char *user_name,
return ret;
}
+#ifdef WITH_LDAP_SAM
+/*******************************************************************
+ Store the LDAP admin password in secrets.tdb
+ ******************************************************************/
+static BOOL store_ldap_admin_pw (char* pw)
+{
+ if (!pw)
+ return False;
+
+ if (!secrets_init())
+ return False;
+
+ return secrets_store_ldap_pw(lp_ldap_admin_dn(), pw);
+}
+#endif
/*************************************************************
Handle password changing for root.
@@ -186,13 +204,16 @@ static int process_root(int argc, char *argv[])
char *new_passwd = NULL;
char *old_passwd = NULL;
char *remote_machine = NULL;
+#ifdef WITH_LDAP_SAM
+ fstring ldap_secret;
+#endif
ZERO_STRUCT(user_name);
ZERO_STRUCT(user_password);
user_name[0] = '\0';
- while ((ch = getopt(argc, argv, "axdehmnjr:sR:D:U:L")) != EOF) {
+ while ((ch = getopt(argc, argv, "axdehmnjr:swR:D:U:L")) != EOF) {
switch(ch) {
case 'L':
local_mode = True;
@@ -228,6 +249,15 @@ static int process_root(int argc, char *argv[])
set_line_buffering(stderr);
stdin_passwd_get = True;
break;
+ case 'w':
+#ifdef WITH_LDAP_SAM
+ local_flags |= LOCAL_SET_LDAP_ADMIN_PW;
+ fstrcpy(ldap_secret, optarg);
+ break;
+#else
+ printf("-w not available unless configured --with-ldap\n");
+ goto done;
+#endif
case 'R':
lp_set_name_resolve_order(optarg);
break;
@@ -259,6 +289,16 @@ static int process_root(int argc, char *argv[])
argc -= optind;
argv += optind;
+#ifdef WITH_LDAP_SAM
+ if (local_flags & LOCAL_SET_LDAP_ADMIN_PW)
+ {
+ printf("Setting stored password for \"%s\" in secrets.tdb\n",
+ lp_ldap_admin_dn());
+ if (!store_ldap_admin_pw(ldap_secret))
+ DEBUG(0,("ERROR: Failed to store the ldap admin password!\n"));
+ goto done;
+ }
+#endif
/*
* Ensure both add/delete user are not set
* Ensure add/delete user and either remote machine or join domain are