diff options
Diffstat (limited to 'source4/setup/setpassword')
-rw-r--r-- | source4/setup/setpassword | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/source4/setup/setpassword b/source4/setup/setpassword index c3357a3cdd..618e304077 100644 --- a/source4/setup/setpassword +++ b/source4/setup/setpassword @@ -78,21 +78,22 @@ if (options['newpassword'] == undefined) { var attrs = new Array("defaultNamingContext"); var attrs2 = new Array("cn"); res = ldb.search("defaultNamingContext=*", "", ldb.SCOPE_BASE, attrs); -assert(res.length == 1 && res[0].defaultNamingContext != undefined); -var domain_dn = res[0].defaultNamingContext; +assert(res.error == 0); +assert(res.msgs.length == 1 && res.msgs[0].defaultNamingContext != undefined); +var domain_dn = res.msgs[0].defaultNamingContext; assert(domain_dn != undefined); if (options['filter'] != undefined) { var res = ldb.search(options['filter'], domain_dn, ldb.SCOPE_SUBTREE, attrs2); - if (res.length != 1) { + if (res.error != 0 || res.msgs.length != 1) { message("Failed to find record for filter %s\n", options['filter']); exit(1); } } else { var res = ldb.search(sprintf("samAccountName=%s", options['username']), domain_dn, ldb.SCOPE_SUBTREE, attrs2); - if (res.length != 1) { + if (res.error != 0 || res.msgs.length != 1) { message("Failed to find record for user %s\n", options['username']); exit(1); } @@ -106,9 +107,9 @@ sambaPassword: %s ", res[0].dn, options['newpassword']); var ok = ldb.modify(mod); -if (!ok) { +if (ok.error != 0) { message("set password for %s failed - %s\n", - res[0].dn, ldb.errstring()); + res[0].dn, ok.errstr); ldb.transaction_cancel(); exit(1); } else { |