mirror of
https://github.com/samba-team/samba.git
synced 2025-12-06 16:23:49 +03:00
r12925: implement client side of ASQ control
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
f3aa702944
commit
dd386bdc6c
@@ -406,6 +406,15 @@ typedef int (*ldb_qsort_cmp_fn_t) (const void *, const void *, const void *);
|
||||
*/
|
||||
#define LDB_CONTROL_SORT_RESP_OID "1.2.840.113556.1.4.474"
|
||||
|
||||
/**
|
||||
OID for LDAP Attribute Scoped Query extension.
|
||||
|
||||
This control is include in SearchRequest or SearchResponse
|
||||
messages as part of the controls field of the LDAPMessage.
|
||||
*/
|
||||
#define LDB_CONTROL_ASQ_OID "1.2.840.113556.1.4.1504"
|
||||
|
||||
|
||||
struct ldb_paged_control {
|
||||
int size;
|
||||
int cookie_len;
|
||||
@@ -427,6 +436,13 @@ struct ldb_sort_resp_control {
|
||||
char *attr_desc;
|
||||
};
|
||||
|
||||
struct ldb_asq_control {
|
||||
int request;
|
||||
char *source_attribute;
|
||||
int src_attr_len;
|
||||
int result;
|
||||
};
|
||||
|
||||
struct ldb_control {
|
||||
const char *oid;
|
||||
int critical;
|
||||
|
||||
@@ -71,6 +71,32 @@ static struct ldb_control **parse_controls(void *mem_ctx, char **control_strings
|
||||
ctrl = talloc_array(mem_ctx, struct ldb_control *, i + 1);
|
||||
|
||||
for (i = 0; control_strings[i]; i++) {
|
||||
if (strncmp(control_strings[i], "asq:", 4) == 0) {
|
||||
struct ldb_asq_control *control;
|
||||
const char *p;
|
||||
char attr[256];
|
||||
int crit, ret;
|
||||
|
||||
attr[0] = '\0';
|
||||
p = &(control_strings[i][4]);
|
||||
ret = sscanf(p, "%d:%255[^$]", &crit, attr);
|
||||
if ((ret != 2) || (crit < 0) || (crit > 1) || (attr[0] == '\0')) {
|
||||
fprintf(stderr, "invalid asq control syntax\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctrl[i] = talloc(ctrl, struct ldb_control);
|
||||
ctrl[i]->oid = LDB_CONTROL_ASQ_OID;
|
||||
ctrl[i]->critical = crit;
|
||||
control = talloc(ctrl[i], struct ldb_asq_control);
|
||||
control->request = 1;
|
||||
control->source_attribute = talloc_strdup(control, attr);
|
||||
control->src_attr_len = strlen(attr);
|
||||
ctrl[i]->data = control;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strncmp(control_strings[i], "extended_dn:", 12) == 0) {
|
||||
struct ldb_extended_dn_control *control;
|
||||
const char *p;
|
||||
@@ -176,6 +202,18 @@ static int handle_controls_reply(struct ldb_control **reply, struct ldb_control
|
||||
if (reply == NULL || request == NULL) return -1;
|
||||
|
||||
for (i = 0; reply[i]; i++) {
|
||||
if (strcmp(LDB_CONTROL_ASQ_OID, reply[i]->oid) == 0) {
|
||||
struct ldb_asq_control *rep_control;
|
||||
|
||||
rep_control = talloc_get_type(reply[i]->data, struct ldb_asq_control);
|
||||
|
||||
/* check the result */
|
||||
if (rep_control->result != 0) {
|
||||
fprintf(stderr, "Warning: ASQ not performed with error: %d\n", rep_control->result);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
if (strcmp(LDB_CONTROL_PAGED_RESULTS_OID, reply[i]->oid) == 0) {
|
||||
struct ldb_paged_control *rep_control, *req_control;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user