Prepare control support
authorVolker Lendecke <vl@samba.org>
Sat, 6 Jun 2009 19:06:33 +0000 (21:06 +0200)
committerVolker Lendecke <vl@samba.org>
Sat, 20 Jun 2009 16:54:06 +0000 (18:54 +0200)
We will have arrays of controls passed to tldap.c. Follow a mantra from the
classic book "Thinking Forth" by Leo Brodie: Favor counts over terminators :-)

This makes the parameter lists to tldap pretty long, but everyone will have
wrapper routines anyway, see for example tldap_search_fmt. And the OpenLDAP
manpages call the non-_ext routines deprecated, probably for a reason.

source3/include/tldap.h
source3/lib/tldap.c
source3/lib/tldap_util.c
source3/passdb/pdb_ads.c

index 96272449e5ba2a0ad983083ddd01f7c47cfb5317..3da7d69d86115b03d6d85b432b70138a3a5efd73 100644 (file)
@@ -58,15 +58,19 @@ struct tevent_req *tldap_sasl_bind_send(TALLOC_CTX *mem_ctx,
                                        const char *dn,
                                        const char *mechanism,
                                        DATA_BLOB *creds,
-                                       struct tldap_control **sctrls,
-                                       struct tldap_control **cctrls);
+                                       struct tldap_control *sctrls,
+                                       int num_sctrls,
+                                       struct tldap_control *cctrls,
+                                       int num_cctrls);
 int tldap_sasl_bind_recv(struct tevent_req *req);
 int tldap_sasl_bind(struct tldap_context *ldap,
                    const char *dn,
                    const char *mechanism,
                    DATA_BLOB *creds,
-                   struct tldap_control **sctrls,
-                   struct tldap_control **cctrls);
+                   struct tldap_control *sctrls,
+                   int num_sctrls,
+                   struct tldap_control *cctrls,
+                   int num_ctrls);
 
 struct tevent_req *tldap_simple_bind_send(TALLOC_CTX *mem_ctx,
                                          struct tevent_context *ev,
@@ -85,8 +89,10 @@ struct tevent_req *tldap_search_send(TALLOC_CTX *mem_ctx,
                                     const char **attrs,
                                     int num_attrs,
                                     int attrsonly,
-                                    struct tldap_control **sctrls,
-                                    struct tldap_control **cctrls,
+                                    struct tldap_control *sctrls,
+                                    int num_sctrls,
+                                    struct tldap_control *cctrls,
+                                    int num_cctrls,
                                     int timelimit,
                                     int sizelimit,
                                     int deref);
@@ -95,7 +101,8 @@ int tldap_search_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
 int tldap_search(struct tldap_context *ld,
                 const char *base, int scope, const char *filter,
                 const char **attrs, int num_attrs, int attrsonly,
-                struct tldap_control **sctrls, struct tldap_control **cctrls,
+                struct tldap_control *sctrls, int num_sctrls,
+                struct tldap_control *cctrls, int num_cctrls,
                 int timelimit, int sizelimit, int deref,
                 TALLOC_CTX *mem_ctx, struct tldap_message ***pentries,
                 struct tldap_message ***refs);
@@ -107,38 +114,45 @@ struct tevent_req *tldap_add_send(TALLOC_CTX *mem_ctx,
                                  struct tevent_context *ev,
                                  struct tldap_context *ld,
                                  const char *dn,
-                                 int num_attributes,
                                  struct tldap_mod *attributes,
-                                 struct tldap_control **sctrls,
-                                 struct tldap_control **cctrls);
+                                 int num_attributes,
+                                 struct tldap_control *sctrls,
+                                 int num_sctrls,
+                                 struct tldap_control *cctrls,
+                                 int num_cctrls);
 int tldap_add_recv(struct tevent_req *req);
 int tldap_add(struct tldap_context *ld, const char *dn,
              int num_attributes, struct tldap_mod *attributes,
-             struct tldap_control **sctrls, struct tldap_control **cctrls);
+             struct tldap_control *sctrls, int num_sctrls,
+             struct tldap_control *cctrls, int num_cctrls);
 
 struct tevent_req *tldap_modify_send(TALLOC_CTX *mem_ctx,
                                     struct tevent_context *ev,
                                     struct tldap_context *ld,
                                     const char *dn,
                                     int num_mods, struct tldap_mod *mods,
-                                    struct tldap_control **sctrls,
-                                    struct tldap_control **cctrls);
+                                    struct tldap_control *sctrls,
+                                    int num_sctrls,
+                                    struct tldap_control *cctrls,
+                                    int num_cctrls);
 int tldap_modify_recv(struct tevent_req *req);
 int tldap_modify(struct tldap_context *ld, const char *dn,
                 int num_mods, struct tldap_mod *mods,
-                struct tldap_control **sctrls, struct tldap_control **cctrls);
-
+                struct tldap_control *sctrls, int num_sctrls,
+                struct tldap_control *cctrls, int num_cctrls);
 
 struct tevent_req *tldap_delete_send(TALLOC_CTX *mem_ctx,
                                     struct tevent_context *ev,
                                     struct tldap_context *ld,
                                     const char *dn,
-                                    struct tldap_control **sctrls,
-                                    struct tldap_control **cctrls);
+                                    struct tldap_control *sctrls,
+                                    int num_sctrls,
+                                    struct tldap_control *cctrls,
+                                    int num_cctrls);
 int tldap_delete_recv(struct tevent_req *req);
 int tldap_delete(struct tldap_context *ld, const char *dn,
-                struct tldap_control **sctrls, struct tldap_control **cctrls);
-
+                struct tldap_control *sctrls, int num_sctrls,
+                struct tldap_control *cctrls, int num_cctrls);
 
 int tldap_msg_id(const struct tldap_message *msg);
 int tldap_msg_type(const struct tldap_message *msg);
index b76e2033a6ad6c1f6acfbf3d82759c15f849342b..8495161b652808a29c891661de8367d1b4f55bb9 100644 (file)
@@ -735,8 +735,10 @@ struct tevent_req *tldap_sasl_bind_send(TALLOC_CTX *mem_ctx,
                                        const char *dn,
                                        const char *mechanism,
                                        DATA_BLOB *creds,
-                                       struct tldap_control **sctrls,
-                                       struct tldap_control **cctrls)
+                                       struct tldap_control *sctrls,
+                                       int num_sctrls,
+                                       struct tldap_control *cctrls,
+                                       int num_cctrls)
 {
        struct tevent_req *req, *subreq;
        struct tldap_req_state *state;
@@ -830,8 +832,10 @@ int tldap_sasl_bind(struct tldap_context *ld,
                    const char *dn,
                    const char *mechanism,
                    DATA_BLOB *creds,
-                   struct tldap_control **sctrls,
-                   struct tldap_control **cctrls)
+                   struct tldap_control *sctrls,
+                   int num_sctrls,
+                   struct tldap_control *cctrls,
+                   int num_cctrls)
 {
        TALLOC_CTX *frame = talloc_stackframe();
        struct tevent_context *ev;
@@ -845,7 +849,7 @@ int tldap_sasl_bind(struct tldap_context *ld,
        }
 
        req = tldap_sasl_bind_send(frame, ev, ld, dn, mechanism, creds,
-                                  sctrls, cctrls);
+                                  sctrls, num_sctrls, cctrls, num_cctrls);
        if (req == NULL) {
                result = TLDAP_NO_MEMORY;
                goto fail;
@@ -878,8 +882,8 @@ struct tevent_req *tldap_simple_bind_send(TALLOC_CTX *mem_ctx,
                cred.data = (uint8_t *)"";
                cred.length = 0;
        }
-       return tldap_sasl_bind_send(mem_ctx, ev, ld, dn, NULL, &cred, NULL,
-                                   NULL);
+       return tldap_sasl_bind_send(mem_ctx, ev, ld, dn, NULL, &cred, NULL, 0,
+                                   NULL, 0);
 }
 
 int tldap_simple_bind_recv(struct tevent_req *req)
@@ -899,7 +903,7 @@ int tldap_simple_bind(struct tldap_context *ld, const char *dn,
                cred.data = (uint8_t *)"";
                cred.length = 0;
        }
-       return tldap_sasl_bind(ld, dn, NULL, &cred, NULL, NULL);
+       return tldap_sasl_bind(ld, dn, NULL, &cred, NULL, 0, NULL, 0);
 }
 
 /*****************************************************************************/
@@ -1088,8 +1092,10 @@ struct tevent_req *tldap_search_send(TALLOC_CTX *mem_ctx,
                                     const char **attrs,
                                     int num_attrs,
                                     int attrsonly,
-                                    struct tldap_control **sctrls,
-                                    struct tldap_control **cctrls,
+                                    struct tldap_control *sctrls,
+                                    int num_sctrls,
+                                    struct tldap_control *cctrls,
+                                    int num_cctrls,
                                     int timelimit,
                                     int sizelimit,
                                     int deref)
@@ -1256,7 +1262,8 @@ static void tldap_search_cb(struct tevent_req *req)
 int tldap_search(struct tldap_context *ld,
                 const char *base, int scope, const char *filter,
                 const char **attrs, int num_attrs, int attrsonly,
-                struct tldap_control **sctrls, struct tldap_control **cctrls,
+                struct tldap_control *sctrls, int num_sctrls,
+                struct tldap_control *cctrls, int num_cctrls,
                 int timelimit, int sizelimit, int deref,
                 TALLOC_CTX *mem_ctx, struct tldap_message ***entries,
                 struct tldap_message ***refs)
@@ -1278,8 +1285,8 @@ int tldap_search(struct tldap_context *ld,
 
        req = tldap_search_send(frame, ev, ld, base, scope, filter,
                                attrs, num_attrs, attrsonly,
-                               sctrls, cctrls, timelimit,
-                               sizelimit, deref);
+                               sctrls, num_sctrls, cctrls, num_cctrls,
+                               timelimit, sizelimit, deref);
        if (req == NULL) {
                state.rc = TLDAP_NO_MEMORY;
                goto fail;
@@ -1454,10 +1461,12 @@ struct tevent_req *tldap_add_send(TALLOC_CTX *mem_ctx,
                                  struct tevent_context *ev,
                                  struct tldap_context *ld,
                                  const char *dn,
-                                 int num_attributes,
                                  struct tldap_mod *attributes,
-                                 struct tldap_control **sctrls,
-                                 struct tldap_control **cctrls)
+                                 int num_attributes,
+                                 struct tldap_control *sctrls,
+                                 int num_sctrls,
+                                 struct tldap_control *cctrls,
+                                 int num_cctrls)
 {
        struct tevent_req *req, *subreq;
        struct tldap_req_state *state;
@@ -1510,7 +1519,8 @@ int tldap_add_recv(struct tevent_req *req)
 
 int tldap_add(struct tldap_context *ld, const char *dn,
              int num_attributes, struct tldap_mod *attributes,
-             struct tldap_control **sctrls, struct tldap_control **cctrls)
+             struct tldap_control *sctrls, int num_sctrls,
+             struct tldap_control *cctrls, int num_cctrls)
 {
        TALLOC_CTX *frame = talloc_stackframe();
        struct tevent_context *ev;
@@ -1523,8 +1533,8 @@ int tldap_add(struct tldap_context *ld, const char *dn,
                goto fail;
        }
 
-       req = tldap_add_send(frame, ev, ld, dn, num_attributes, attributes,
-                            sctrls, cctrls);
+       req = tldap_add_send(frame, ev, ld, dn, attributes, num_attributes,
+                            sctrls, num_sctrls, cctrls, num_cctrls);
        if (req == NULL) {
                result = TLDAP_NO_MEMORY;
                goto fail;
@@ -1549,8 +1559,10 @@ struct tevent_req *tldap_modify_send(TALLOC_CTX *mem_ctx,
                                     struct tldap_context *ld,
                                     const char *dn,
                                     int num_mods, struct tldap_mod *mods,
-                                    struct tldap_control **sctrls,
-                                    struct tldap_control **cctrls)
+                                    struct tldap_control *sctrls,
+                                    int num_sctrls,
+                                    struct tldap_control *cctrls,
+                                    int num_cctrls)
 {
        struct tevent_req *req, *subreq;
        struct tldap_req_state *state;
@@ -1606,7 +1618,8 @@ int tldap_modify_recv(struct tevent_req *req)
 
 int tldap_modify(struct tldap_context *ld, const char *dn,
                 int num_mods, struct tldap_mod *mods,
-                struct tldap_control **sctrls, struct tldap_control **cctrls)
+                struct tldap_control *sctrls, int num_sctrls,
+                struct tldap_control *cctrls, int num_cctrls)
  {
        TALLOC_CTX *frame = talloc_stackframe();
        struct tevent_context *ev;
@@ -1620,7 +1633,7 @@ int tldap_modify(struct tldap_context *ld, const char *dn,
        }
 
        req = tldap_modify_send(frame, ev, ld, dn, num_mods, mods,
-                               sctrls, cctrls);
+                               sctrls, num_sctrls, cctrls, num_cctrls);
        if (req == NULL) {
                result = TLDAP_NO_MEMORY;
                goto fail;
@@ -1644,8 +1657,10 @@ struct tevent_req *tldap_delete_send(TALLOC_CTX *mem_ctx,
                                     struct tevent_context *ev,
                                     struct tldap_context *ld,
                                     const char *dn,
-                                    struct tldap_control **sctrls,
-                                    struct tldap_control **cctrls)
+                                    struct tldap_control *sctrls,
+                                    int num_sctrls,
+                                    struct tldap_control *cctrls,
+                                    int num_cctrls)
 {
        struct tevent_req *req, *subreq;
        struct tldap_req_state *state;
@@ -1678,7 +1693,8 @@ int tldap_delete_recv(struct tevent_req *req)
 }
 
 int tldap_delete(struct tldap_context *ld, const char *dn,
-                struct tldap_control **sctrls, struct tldap_control **cctrls)
+                struct tldap_control *sctrls, int num_sctrls,
+                struct tldap_control *cctrls, int num_cctrls)
 {
        TALLOC_CTX *frame = talloc_stackframe();
        struct tevent_context *ev;
@@ -1691,7 +1707,8 @@ int tldap_delete(struct tldap_context *ld, const char *dn,
                goto fail;
        }
 
-       req = tldap_delete_send(frame, ev, ld, dn, sctrls, cctrls);
+       req = tldap_delete_send(frame, ev, ld, dn, sctrls, num_sctrls,
+                               cctrls, num_cctrls);
        if (req == NULL) {
                result = TLDAP_NO_MEMORY;
                goto fail;
index 042665f15f63319e060d7a4c652b6b4286425f44..3698264bd631137abcaba99a1b8ca31979397ade 100644 (file)
@@ -343,7 +343,7 @@ int tldap_search_fmt(struct tldap_context *ld, const char *base, int scope,
        }
        ret = tldap_search(ld, base, scope, filter,
                           attrs, num_attrs, attrsonly,
-                          NULL /*sctrls*/, NULL /*cctrls*/,
+                          NULL /*sctrls*/, 0, NULL /*cctrls*/, 0,
                           0 /*timelimit*/, 0 /*sizelimit*/, 0 /*deref*/,
                           mem_ctx, res, NULL);
        TALLOC_FREE(filter);
@@ -404,7 +404,7 @@ struct tevent_req *tldap_fetch_rootdse_send(TALLOC_CTX *mem_ctx,
 
        subreq = tldap_search_send(
                mem_ctx, ev, ld, "", TLDAP_SCOPE_BASE, "(objectclass=*)",
-               attrs, ARRAY_SIZE(attrs), 0, NULL, NULL, 0, 0, 0);
+               attrs, ARRAY_SIZE(attrs), 0, NULL, 0, NULL, 0, 0, 0, 0);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
index 4bd0b89d6da3bbc45f73ee1954fffd3baa44689f..d7a5db6b03d323517d7f266de44f006536217b74 100644 (file)
@@ -400,7 +400,7 @@ static NTSTATUS pdb_ads_create_user(struct pdb_methods *m,
                return NT_STATUS_NO_MEMORY;
        }
 
-       rc = tldap_add(state->ld, dn, num_mods, mods, NULL, NULL);
+       rc = tldap_add(state->ld, dn, num_mods, mods, NULL, 0, NULL, 0);
        if (rc != TLDAP_SUCCESS) {
                DEBUG(10, ("ldap_add failed %s\n",
                           tldap_errstr(debug_ctx(), state->ld, rc)));
@@ -454,7 +454,7 @@ static NTSTATUS pdb_ads_delete_user(struct pdb_methods *m,
                return status;
        }
 
-       rc = tldap_delete(state->ld, dn, NULL, NULL);
+       rc = tldap_delete(state->ld, dn, NULL, 0, NULL, 0);
        TALLOC_FREE(dn);
        if (rc != TLDAP_SUCCESS) {
                DEBUG(10, ("ldap_delete for %s failed: %s\n", dn,
@@ -489,7 +489,8 @@ static NTSTATUS pdb_ads_update_sam_account(struct pdb_methods *m,
                return NT_STATUS_OK;
        }
 
-       rc = tldap_modify(state->ld, priv->dn, num_mods, mods, NULL, NULL);
+       rc = tldap_modify(state->ld, priv->dn, num_mods, mods, NULL, 0,
+                         NULL, 0);
        if (rc != TLDAP_SUCCESS) {
                DEBUG(10, ("ldap_modify for %s failed: %s\n", priv->dn,
                           tldap_errstr(debug_ctx(), state->ld, rc)));
@@ -669,7 +670,7 @@ static NTSTATUS pdb_ads_create_dom_group(struct pdb_methods *m,
                return NT_STATUS_NO_MEMORY;
        }
 
-       rc = tldap_add(state->ld, dn, num_mods, mods, NULL, NULL);
+       rc = tldap_add(state->ld, dn, num_mods, mods, NULL, 0, NULL, 0);
        if (rc != TLDAP_SUCCESS) {
                DEBUG(10, ("ldap_add failed %s\n",
                           tldap_errstr(debug_ctx(), state->ld, rc)));
@@ -747,7 +748,7 @@ static NTSTATUS pdb_ads_delete_dom_group(struct pdb_methods *m,
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
 
-       rc = tldap_delete(state->ld, dn, NULL, NULL);
+       rc = tldap_delete(state->ld, dn, NULL, 0, NULL, 0);
        if (rc != TLDAP_SUCCESS) {
                DEBUG(10, ("ldap_delete failed: %s\n",
                           tldap_errstr(debug_ctx(), state->ld, rc)));
@@ -952,7 +953,7 @@ static NTSTATUS pdb_ads_mod_groupmem(struct pdb_methods *m,
                return NT_STATUS_NO_MEMORY;
        }
 
-       rc = tldap_modify(state->ld, groupdn, 1, mods, NULL, NULL);
+       rc = tldap_modify(state->ld, groupdn, 1, mods, NULL, 0, NULL, 0);
        TALLOC_FREE(frame);
        if (rc != TLDAP_SUCCESS) {
                DEBUG(10, ("ldap_modify failed: %s\n",
@@ -1021,7 +1022,7 @@ static NTSTATUS pdb_ads_create_alias(struct pdb_methods *m,
                return NT_STATUS_NO_MEMORY;
        }
 
-       rc = tldap_add(state->ld, dn, num_mods, mods, NULL, NULL);
+       rc = tldap_add(state->ld, dn, num_mods, mods, NULL, 0, NULL, 0);
        if (rc != TLDAP_SUCCESS) {
                DEBUG(10, ("ldap_add failed %s\n",
                           tldap_errstr(debug_ctx(), state->ld, rc)));
@@ -1097,7 +1098,7 @@ static NTSTATUS pdb_ads_delete_alias(struct pdb_methods *m,
                return NT_STATUS_INTERNAL_ERROR;
        }
 
-       rc = tldap_delete(state->ld, dn, NULL, NULL);
+       rc = tldap_delete(state->ld, dn, NULL, 0, NULL, 0);
        if (rc != TLDAP_SUCCESS) {
                DEBUG(10, ("ldap_delete failed: %s\n",
                           tldap_errstr(debug_ctx(), state->ld, rc)));
@@ -1172,7 +1173,7 @@ static NTSTATUS pdb_ads_set_aliasinfo(struct pdb_methods *m,
                return NT_STATUS_OK;
        }
 
-       rc = tldap_modify(state->ld, dn, num_mods, mods, NULL, NULL);
+       rc = tldap_modify(state->ld, dn, num_mods, mods, NULL, 0, NULL, 0);
        TALLOC_FREE(msg);
        if (rc != TLDAP_SUCCESS) {
                DEBUG(10, ("ldap_modify failed: %s\n",
@@ -1262,7 +1263,7 @@ static NTSTATUS pdb_ads_mod_aliasmem(struct pdb_methods *m,
                return NT_STATUS_NO_MEMORY;
        }
 
-       rc = tldap_modify(state->ld, aliasdn, 1, mods, NULL, NULL);
+       rc = tldap_modify(state->ld, aliasdn, 1, mods, NULL, 0, NULL, 0);
        TALLOC_FREE(frame);
        if (rc != TLDAP_SUCCESS) {
                DEBUG(10, ("ldap_modify failed: %s\n",