summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-06-06 21:06:33 +0200
committerVolker Lendecke <vl@samba.org>2009-06-20 18:54:06 +0200
commit63a70ba0ad306e39311db3145d85323276e02c02 (patch)
tree80d2477357b87cec984e3a4cba73a906ffc4ae53 /source3
parent62eb817c06458070d090c1698e9c0a99914c6d78 (diff)
downloadsamba-63a70ba0ad306e39311db3145d85323276e02c02.tar.gz
samba-63a70ba0ad306e39311db3145d85323276e02c02.tar.bz2
samba-63a70ba0ad306e39311db3145d85323276e02c02.zip
Prepare control support
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.
Diffstat (limited to 'source3')
-rw-r--r--source3/include/tldap.h52
-rw-r--r--source3/lib/tldap.c71
-rw-r--r--source3/lib/tldap_util.c4
-rw-r--r--source3/passdb/pdb_ads.c21
4 files changed, 90 insertions, 58 deletions
diff --git a/source3/include/tldap.h b/source3/include/tldap.h
index 96272449e5..3da7d69d86 100644
--- a/source3/include/tldap.h
+++ b/source3/include/tldap.h
@@ -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);
diff --git a/source3/lib/tldap.c b/source3/lib/tldap.c
index b76e2033a6..8495161b65 100644
--- a/source3/lib/tldap.c
+++ b/source3/lib/tldap.c
@@ -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;
diff --git a/source3/lib/tldap_util.c b/source3/lib/tldap_util.c
index 042665f15f..3698264bd6 100644
--- a/source3/lib/tldap_util.c
+++ b/source3/lib/tldap_util.c
@@ -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);
}
diff --git a/source3/passdb/pdb_ads.c b/source3/passdb/pdb_ads.c
index 4bd0b89d6d..d7a5db6b03 100644
--- a/source3/passdb/pdb_ads.c
+++ b/source3/passdb/pdb_ads.c
@@ -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",