summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/common/util.c87
-rw-r--r--source4/dsdb/samdb/cracknames.c1
-rw-r--r--source4/dsdb/samdb/ldb_modules/samba3sid.c1
-rw-r--r--source4/dsdb/samdb/ldb_modules/samldb.c1
-rw-r--r--source4/dsdb/samdb/samdb.c1
-rw-r--r--source4/dsdb/samdb/samdb_privilege.c1
-rw-r--r--source4/dsdb/wscript_build2
7 files changed, 87 insertions, 7 deletions
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c
index 9e6ccbc911..b7f6b69fce 100644
--- a/source4/dsdb/common/util.c
+++ b/source4/dsdb/common/util.c
@@ -26,7 +26,6 @@
#include "ldb.h"
#include "ldb_module.h"
#include "ldb_errors.h"
-#include "../lib/util/util_ldb.h"
#include "../lib/crypto/crypto.h"
#include "dsdb/samdb/samdb.h"
#include "libcli/security/security.h"
@@ -45,6 +44,92 @@
#include "librpc/gen_ndr/irpc.h"
/*
+ * search the SAMDB for the specified attributes - va_list variant
+ */
+int gendb_search_v(struct ldb_context *ldb,
+ TALLOC_CTX *mem_ctx,
+ struct ldb_dn *basedn,
+ struct ldb_message ***msgs,
+ const char * const *attrs,
+ const char *format,
+ va_list ap)
+{
+ enum ldb_scope scope = LDB_SCOPE_SUBTREE;
+ struct ldb_result *res;
+ char *expr = NULL;
+ int ret;
+
+ if (format) {
+ expr = talloc_vasprintf(mem_ctx, format, ap);
+ if (expr == NULL) {
+ return -1;
+ }
+ } else {
+ scope = LDB_SCOPE_BASE;
+ }
+
+ res = NULL;
+
+ ret = ldb_search(ldb, mem_ctx, &res, basedn, scope, attrs,
+ expr?"%s":NULL, expr);
+
+ if (ret == LDB_SUCCESS) {
+ talloc_steal(mem_ctx, res->msgs);
+
+ DEBUG(6,("gendb_search_v: %s %s -> %d\n",
+ basedn?ldb_dn_get_linearized(basedn):"NULL",
+ expr?expr:"NULL", res->count));
+
+ ret = res->count;
+ *msgs = res->msgs;
+ talloc_free(res);
+ } else if (scope == LDB_SCOPE_BASE && ret == LDB_ERR_NO_SUCH_OBJECT) {
+ ret = 0;
+ *msgs = NULL;
+ } else {
+ DEBUG(4,("gendb_search_v: search failed: %s\n",
+ ldb_errstring(ldb)));
+ ret = -1;
+ }
+
+ talloc_free(expr);
+
+ return ret;
+}
+
+/*
+ * search the SAMDB for the specified attributes - varargs variant
+ */
+int gendb_search(struct ldb_context *ldb,
+ TALLOC_CTX *mem_ctx,
+ struct ldb_dn *basedn,
+ struct ldb_message ***res,
+ const char * const *attrs,
+ const char *format, ...)
+{
+ va_list ap;
+ int count;
+
+ va_start(ap, format);
+ count = gendb_search_v(ldb, mem_ctx, basedn, res, attrs, format, ap);
+ va_end(ap);
+
+ return count;
+}
+
+/*
+ * search the SAMDB for a specified record (by DN)
+ */
+int gendb_search_dn(struct ldb_context *ldb,
+ TALLOC_CTX *mem_ctx,
+ struct ldb_dn *dn,
+ struct ldb_message ***res,
+ const char * const *attrs)
+{
+ return gendb_search(ldb, mem_ctx, dn, res, attrs, NULL);
+}
+
+/*
search the sam for the specified attributes in a specific domain, filter on
objectSid being in domain_sid.
*/
diff --git a/source4/dsdb/samdb/cracknames.c b/source4/dsdb/samdb/cracknames.c
index 6df140fed3..d4b122056b 100644
--- a/source4/dsdb/samdb/cracknames.c
+++ b/source4/dsdb/samdb/cracknames.c
@@ -32,7 +32,6 @@
#include "libcli/ldap/ldap_ndr.h"
#include "libcli/security/security.h"
#include "auth/auth.h"
-#include "../lib/util/util_ldb.h"
#include "dsdb/samdb/samdb.h"
#include "dsdb/common/util.h"
#include "param/param.h"
diff --git a/source4/dsdb/samdb/ldb_modules/samba3sid.c b/source4/dsdb/samdb/ldb_modules/samba3sid.c
index a5b3df185c..f6db0d1948 100644
--- a/source4/dsdb/samdb/ldb_modules/samba3sid.c
+++ b/source4/dsdb/samdb/ldb_modules/samba3sid.c
@@ -29,7 +29,6 @@
#include "dsdb/samdb/ldb_modules/util.h"
#include "libcli/security/security.h"
#include "librpc/gen_ndr/ndr_security.h"
-#include "../lib/util/util_ldb.h"
#include "ldb_wrap.h"
#include "param/param.h"
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index 3a971e80c5..8db93b2a8a 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -37,7 +37,6 @@
#include "dsdb/samdb/ldb_modules/ridalloc.h"
#include "libcli/security/security.h"
#include "librpc/gen_ndr/ndr_security.h"
-#include "../lib/util/util_ldb.h"
#include "ldb_wrap.h"
#include "param/param.h"
diff --git a/source4/dsdb/samdb/samdb.c b/source4/dsdb/samdb/samdb.c
index c7d2c3085d..93fc122d21 100644
--- a/source4/dsdb/samdb/samdb.c
+++ b/source4/dsdb/samdb/samdb.c
@@ -34,7 +34,6 @@
#include "system/time.h"
#include "system/filesys.h"
#include "ldb_wrap.h"
-#include "../lib/util/util_ldb.h"
#include "dsdb/samdb/samdb.h"
#include "../libds/common/flags.h"
#include "param/param.h"
diff --git a/source4/dsdb/samdb/samdb_privilege.c b/source4/dsdb/samdb/samdb_privilege.c
index 69c4ebea61..e6d9a9a032 100644
--- a/source4/dsdb/samdb/samdb_privilege.c
+++ b/source4/dsdb/samdb/samdb_privilege.c
@@ -24,7 +24,6 @@
#include "dsdb/samdb/samdb.h"
#include "auth/auth.h"
#include "libcli/security/security.h"
-#include "../lib/util/util_ldb.h"
#include "param/param.h"
#include "ldb_wrap.h"
diff --git a/source4/dsdb/wscript_build b/source4/dsdb/wscript_build
index db2f38b1b1..832adb7d1d 100644
--- a/source4/dsdb/wscript_build
+++ b/source4/dsdb/wscript_build
@@ -14,7 +14,7 @@ bld.SAMBA_LIBRARY('SAMDB',
bld.SAMBA_SUBSYSTEM('SAMDB_COMMON',
source='common/util.c common/util_samr.c common/dsdb_dn.c common/dsdb_access.c ../../libds/common/flag_mapping.c',
autoproto='common/proto.h',
- deps='ldb NDR_DRSBLOBS LIBCLI_LDAP_NDR UTIL_LDB LIBCLI_AUTH LIBTSOCKET samba_socket LIBSAMBA-HOSTCONFIG'
+ deps='ldb NDR_DRSBLOBS LIBCLI_LDAP_NDR LIBCLI_AUTH LIBTSOCKET samba_socket LIBSAMBA-HOSTCONFIG'
)