]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
dsdb: Add dsdb_search_scope_as_string() and use in ldap_backend.c
authorAndrew Bartlett <abartlet@samba.org>
Mon, 31 Jul 2023 04:02:25 +0000 (16:02 +1200)
committerStefan Metzmacher <metze@samba.org>
Mon, 31 Jul 2023 10:56:54 +0000 (10:56 +0000)
This will be useful when adding debugging to other routines.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source4/dsdb/common/util.c
source4/ldap_server/ldap_backend.c

index 5fa9f65e247aa9fdb0f20ed74a013a644afc8165..f055181e1e77f29d8a2b273c70156ca9d16bd42b 100644 (file)
@@ -5277,6 +5277,27 @@ int dsdb_replace(struct ldb_context *ldb, struct ldb_message *msg, uint32_t dsdb
        return dsdb_modify(ldb, msg, dsdb_flags);
 }
 
+const char *dsdb_search_scope_as_string(enum ldb_scope scope)
+{
+       const char *scope_str;
+
+       switch (scope) {
+       case LDB_SCOPE_BASE:
+               scope_str = "BASE";
+               break;
+       case LDB_SCOPE_ONELEVEL:
+               scope_str = "ONE";
+               break;
+       case LDB_SCOPE_SUBTREE:
+               scope_str = "SUB";
+               break;
+       default:
+               scope_str = "<Invalid scope>";
+               break;
+       }
+       return scope_str;
+}
+
 
 /*
   search for attrs on one DN, allowing for dsdb_flags controls
index dbb9c1e7a0ad04450c412c62853c7d7519f9f99a..a32856506be8bbefaf17bd800577ef59565ffb5e 100644 (file)
@@ -770,15 +770,12 @@ static NTSTATUS ldapsrv_SearchRequest(struct ldapsrv_call *call)
 
        switch (req->scope) {
        case LDAP_SEARCH_SCOPE_BASE:
-               scope_str = "BASE";
                scope = LDB_SCOPE_BASE;
                break;
        case LDAP_SEARCH_SCOPE_SINGLE:
-               scope_str = "ONE";
                scope = LDB_SCOPE_ONELEVEL;
                break;
        case LDAP_SEARCH_SCOPE_SUB:
-               scope_str = "SUB";
                scope = LDB_SCOPE_SUBTREE;
                break;
        default:
@@ -790,6 +787,8 @@ static NTSTATUS ldapsrv_SearchRequest(struct ldapsrv_call *call)
                                         "%s. Invalid scope", errstr);
                goto reply;
        }
+       scope_str = dsdb_search_scope_as_string(scope);
+
        DEBUG(10,("SearchRequest: scope: [%s]\n", scope_str));
 
        if (req->num_attributes >= 1) {