Logo Search packages:      
Sourcecode: ldb version File versions  Download package

int ldb_search ( struct ldb_context *  ldb,
struct ldb_dn *  base,
enum ldb_scope  scope,
const char *  expression,
const char *const *  attrs,
struct ldb_result **  res 
)

Search the database

This function searches the database, and returns records that match an LDAP-like search expression

Parameters:
ldb the context associated with the database (from ldb_init())
base the Base Distinguished Name for the query (use ldb_dn_new() for an empty one)
scope the search scope for the query
expression the search expression to use for this query
attrs the search attributes for the query (pass NULL if none required)
res the return result
Returns:
result code (LDB_SUCCESS on success, or a failure code)
Note:
use talloc_free() to free the ldb_result returned

Definition at line 904 of file ldb.c.

References LDB_ERR_OPERATIONS_ERROR, and LDB_SUCCESS.

{
      struct ldb_request *req;
      int ret;
      struct ldb_result *res;

      *_res = NULL;

      res = talloc_zero(ldb, struct ldb_result);
      if (!res) {
            return LDB_ERR_OPERATIONS_ERROR;
      }

      ret = ldb_build_search_req(&req, ldb, ldb,
                              base?base:ldb_get_default_basedn(ldb),
                                    scope,
                              expression,
                              attrs,
                              NULL,
                              res,
                              ldb_search_default_callback);

      if (ret != LDB_SUCCESS) goto done;

      ldb_set_timeout(ldb, req, 0); /* use default timeout */

      ret = ldb_request(ldb, req);
      
      if (ret == LDB_SUCCESS) {
            ret = ldb_wait(req->handle, LDB_WAIT_ALL);
      }

      talloc_free(req);

done:
      if (ret != LDB_SUCCESS) {
            talloc_free(res);
      }

      *_res = res;
      return ret;
}


Generated by  Doxygen 1.6.0   Back to index