summaryrefslogtreecommitdiff
path: root/source4/passdb
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2005-09-25 21:01:56 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:38:54 -0500
commit9593101ec118dd242bf25fabf3e17c58269e632c (patch)
treec06ef0370effd18294efff90624a177dae059bb7 /source4/passdb
parent06085e7bc09e46c74fbe050633203fab619d501c (diff)
downloadsamba-9593101ec118dd242bf25fabf3e17c58269e632c.tar.gz
samba-9593101ec118dd242bf25fabf3e17c58269e632c.tar.bz2
samba-9593101ec118dd242bf25fabf3e17c58269e632c.zip
r10491: First step towards wbinfo -t: This issues a name request for the primary
domain and gets the DC's name via a mailslot call. Metze, I renamed wbsrv_queue_reply to wbsrv_send_reply in accordance with irpc_send_reply. Having _queue_ here and _send_ there is a bit confusing. And as everything is async anyway, the semantics should not be too much of a problem. Volker (This used to be commit 4637964b19c6e9f7d201b287e2d409d029fced01)
Diffstat (limited to 'source4/passdb')
-rw-r--r--source4/passdb/secrets.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/source4/passdb/secrets.c b/source4/passdb/secrets.c
index 356847c6ee..13f82f61fd 100644
--- a/source4/passdb/secrets.c
+++ b/source4/passdb/secrets.c
@@ -28,6 +28,7 @@
#include "system/filesys.h"
#include "pstring.h"
#include "db_wrap.h"
+#include "lib/ldb/include/ldb.h"
static struct tdb_wrap *tdb;
@@ -153,3 +154,45 @@ struct ldb_context *secrets_db_connect(TALLOC_CTX *mem_ctx)
return ldb;
}
+struct dom_sid *secrets_get_domain_sid(TALLOC_CTX *mem_ctx,
+ const char *domain)
+{
+ struct ldb_context *ldb;
+ struct ldb_message **msgs;
+ int ldb_ret;
+ const char *attrs[] = { "objectSid", NULL };
+ struct dom_sid *result = NULL;
+
+ ldb = secrets_db_connect(mem_ctx);
+ if (ldb == NULL) {
+ DEBUG(5, ("secrets_db_connect failed\n"));
+ goto done;
+ }
+
+ ldb_ret = gendb_search(ldb, ldb,
+ ldb_dn_explode(mem_ctx, SECRETS_PRIMARY_DOMAIN_DN),
+ &msgs, attrs,
+ SECRETS_PRIMARY_DOMAIN_FILTER, domain);
+
+ if (ldb_ret == 0) {
+ DEBUG(5, ("Did not find domain record for %s\n", domain));
+ goto done;
+ }
+
+ if (ldb_ret > 1) {
+ DEBUG(5, ("Found more than one (%d) domain records for %s\n",
+ ldb_ret, domain));
+ goto done;
+ }
+
+ result = samdb_result_dom_sid(mem_ctx, msgs[0], "objectSid");
+ if (result == NULL) {
+ DEBUG(0, ("Domain object for %s does not contain a SID!\n",
+ domain));
+ goto done;
+ }
+
+ done:
+ talloc_free(ldb);
+ return result;
+}