summaryrefslogtreecommitdiff
path: root/source3/utils/net_sam.c
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2011-11-15 23:56:38 +0100
committerGünther Deschner <gd@samba.org>2011-11-16 12:26:26 +0100
commit65e2944c678a7d4d111ee00e9e964fde14b163a6 (patch)
treef583a2ed29949dc794b95f6e2966b6d4deb13296 /source3/utils/net_sam.c
parentaf50d7a57fcc69d0bc5928410618f253071e9759 (diff)
downloadsamba-65e2944c678a7d4d111ee00e9e964fde14b163a6.tar.gz
s3-smbldap: extend smbldap_init() with binddn/bindsecret arguments.
Guenther
Diffstat (limited to 'source3/utils/net_sam.c')
-rw-r--r--source3/utils/net_sam.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/source3/utils/net_sam.c b/source3/utils/net_sam.c
index 7798fbb9080..7163e663f87 100644
--- a/source3/utils/net_sam.c
+++ b/source3/utils/net_sam.c
@@ -29,6 +29,7 @@
#include "passdb/pdb_ldap_util.h"
#include "passdb/pdb_ldap_schema.h"
#include "lib/privileges.h"
+#include "secrets.h"
/*
* Set a user's data
@@ -1591,6 +1592,9 @@ static int net_sam_provision(struct net_context *c, int argc, const char **argv)
struct samu *samuser;
struct passwd *pwd;
bool is_ipa = false;
+ char *bind_dn = NULL;
+ char *bind_secret = NULL;
+ NTSTATUS status;
if (c->display_usage) {
d_printf( "%s\n"
@@ -1645,7 +1649,18 @@ static int net_sam_provision(struct net_context *c, int argc, const char **argv)
goto failed;
}
- if (!NT_STATUS_IS_OK(smbldap_init(tc, NULL, ldap_uri, &state))) {
+ if (!fetch_ldap_pw(&bind_dn, &bind_secret)) {
+ d_fprintf(stderr, _("Failed to retrieve LDAP password from secrets.tdb\n"));
+ goto failed;
+ }
+
+ status = smbldap_init(tc, NULL, ldap_uri, false, bind_dn, bind_secret, &state);
+
+ memset(bind_secret, '\0', strlen(bind_secret));
+ SAFE_FREE(bind_secret);
+ SAFE_FREE(bind_dn);
+
+ if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, _("Unable to connect to the LDAP server.\n"));
goto failed;
}