summaryrefslogtreecommitdiff
path: root/source4/ldap_server
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2008-12-16 08:44:11 +0100
committerAndrew Bartlett <abartlet@samba.org>2008-12-17 12:29:26 +1100
commite4ccd69d496cca1f85fcb6fb3ca3509435914ad0 (patch)
tree3a788685c0c7b95fc2b728344a5955db19009ff4 /source4/ldap_server
parent408a752a63ae83dcd32008295ee2a5bfe9a96085 (diff)
downloadsamba-e4ccd69d496cca1f85fcb6fb3ca3509435914ad0.tar.gz
samba-e4ccd69d496cca1f85fcb6fb3ca3509435914ad0.tar.bz2
samba-e4ccd69d496cca1f85fcb6fb3ca3509435914ad0.zip
s4:ldap_server: return the extended dn to the LDAP client if available
This uses an early peek at the extended_dn_control (in the request) to see what output format to use. Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source4/ldap_server')
-rw-r--r--source4/ldap_server/ldap_backend.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/source4/ldap_server/ldap_backend.c b/source4/ldap_server/ldap_backend.c
index 2adff2a1df..a091c1d11e 100644
--- a/source4/ldap_server/ldap_backend.c
+++ b/source4/ldap_server/ldap_backend.c
@@ -159,6 +159,8 @@ static NTSTATUS ldapsrv_SearchRequest(struct ldapsrv_call *call)
struct ldb_request *lreq;
struct ldb_control *search_control;
struct ldb_search_options_control *search_options;
+ struct ldb_control *extended_dn_control;
+ struct ldb_extended_dn_control *extended_dn_decoded = NULL;
enum ldb_scope scope = LDB_SCOPE_DEFAULT;
const char **attrs = NULL;
const char *scope_str, *errstr = NULL;
@@ -166,6 +168,7 @@ static NTSTATUS ldapsrv_SearchRequest(struct ldapsrv_call *call)
int result = -1;
int ldb_ret = -1;
int i, j;
+ int extended_type = 1;
DEBUG(10, ("SearchRequest"));
DEBUGADD(10, (" basedn: %s", req->basedn));
@@ -245,6 +248,18 @@ static NTSTATUS ldapsrv_SearchRequest(struct ldapsrv_call *call)
ldb_request_add_control(lreq, LDB_CONTROL_SEARCH_OPTIONS_OID, false, search_options);
}
}
+
+ extended_dn_control = ldb_request_get_control(lreq, LDB_CONTROL_EXTENDED_DN_OID);
+
+ if (extended_dn_control) {
+ if (extended_dn_control->data) {
+ extended_dn_decoded = talloc_get_type(extended_dn_control->data, struct ldb_extended_dn_control);
+ extended_type = extended_dn_decoded->type;
+ } else {
+ extended_type = 0;
+ }
+ }
+
ldb_set_timeout(samdb, lreq, req->timelimit);
ldb_ret = ldb_request(samdb, lreq);
@@ -266,7 +281,7 @@ static NTSTATUS ldapsrv_SearchRequest(struct ldapsrv_call *call)
talloc_steal(ent_r, res->msgs[i]);
ent = &ent_r->msg->r.SearchResultEntry;
- ent->dn = ldb_dn_alloc_linearized(ent_r, res->msgs[i]->dn);
+ ent->dn = ldb_dn_get_extended_linearized(ent_r, res->msgs[i]->dn, extended_type);
ent->num_attributes = 0;
ent->attributes = NULL;
if (res->msgs[i]->num_elements == 0) {