summaryrefslogtreecommitdiff
path: root/libcli/cldap
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2013-10-28 14:19:57 +0100
committerAndrew Bartlett <abartlet@samba.org>2013-11-11 23:00:55 +0100
commite306250a250d20a43cbe4c72ece34ebd475fa39c (patch)
treebea16e132d2b4e8be8e223358da8e9c276907202 /libcli/cldap
parent68ebb09193e73cff4389ccb9e3b190b12ee0a84a (diff)
downloadsamba-e306250a250d20a43cbe4c72ece34ebd475fa39c.tar.gz
libcli/cldap: Add utility to create netlogon filter
This utility is splitted of from cldap_netlogon_send. Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Nadezhda Ivanova <nivanova@symas.com>
Diffstat (limited to 'libcli/cldap')
-rw-r--r--libcli/cldap/cldap.c90
-rw-r--r--libcli/cldap/cldap.h2
2 files changed, 52 insertions, 40 deletions
diff --git a/libcli/cldap/cldap.c b/libcli/cldap/cldap.c
index 24ce39fefb6..e54309190a0 100644
--- a/libcli/cldap/cldap.c
+++ b/libcli/cldap/cldap.c
@@ -882,81 +882,91 @@ struct cldap_netlogon_state {
struct cldap_search search;
};
-static void cldap_netlogon_state_done(struct tevent_req *subreq);
-/*
- queue a cldap netlogon for send
-*/
-struct tevent_req *cldap_netlogon_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct cldap_socket *cldap,
- const struct cldap_netlogon *io)
+char *cldap_netlogon_create_filter(TALLOC_CTX *mem_ctx,
+ const struct cldap_netlogon *io)
{
- struct tevent_req *req, *subreq;
- struct cldap_netlogon_state *state;
char *filter;
- static const char * const attr[] = { "NetLogon", NULL };
- req = tevent_req_create(mem_ctx, &state,
- struct cldap_netlogon_state);
- if (!req) {
+ filter = talloc_asprintf(mem_ctx, "(&(NtVer=%s)",
+ ldap_encode_ndr_uint32(mem_ctx, io->in.version));
+ if (filter == NULL)
return NULL;
- }
- filter = talloc_asprintf(state, "(&(NtVer=%s)",
- ldap_encode_ndr_uint32(state, io->in.version));
- if (tevent_req_nomem(filter, req)) {
- goto post;
- }
if (io->in.user) {
filter = talloc_asprintf_append_buffer(filter, "(User=%s)", io->in.user);
- if (tevent_req_nomem(filter, req)) {
- goto post;
+ if (filter == NULL) {
+ return NULL;
}
}
if (io->in.host) {
filter = talloc_asprintf_append_buffer(filter, "(Host=%s)", io->in.host);
- if (tevent_req_nomem(filter, req)) {
- goto post;
+ if (filter == NULL) {
+ return NULL;
}
}
if (io->in.realm) {
filter = talloc_asprintf_append_buffer(filter, "(DnsDomain=%s)", io->in.realm);
- if (tevent_req_nomem(filter, req)) {
- goto post;
+ if (filter == NULL) {
+ return NULL;
}
}
if (io->in.acct_control != -1) {
filter = talloc_asprintf_append_buffer(filter, "(AAC=%s)",
- ldap_encode_ndr_uint32(state, io->in.acct_control));
- if (tevent_req_nomem(filter, req)) {
- goto post;
+ ldap_encode_ndr_uint32(mem_ctx, io->in.acct_control));
+ if (filter == NULL) {
+ return NULL;
}
}
if (io->in.domain_sid) {
- struct dom_sid *sid = dom_sid_parse_talloc(state, io->in.domain_sid);
- if (tevent_req_nomem(sid, req)) {
- goto post;
+ struct dom_sid *sid = dom_sid_parse_talloc(mem_ctx, io->in.domain_sid);
+ if (filter == NULL) {
+ return NULL;
}
filter = talloc_asprintf_append_buffer(filter, "(domainSid=%s)",
- ldap_encode_ndr_dom_sid(state, sid));
- if (tevent_req_nomem(filter, req)) {
- goto post;
+ ldap_encode_ndr_dom_sid(mem_ctx, sid));
+ if (filter == NULL) {
+ return NULL;
}
}
if (io->in.domain_guid) {
struct GUID guid;
NTSTATUS status;
status = GUID_from_string(io->in.domain_guid, &guid);
- if (tevent_req_nterror(req, status)) {
- goto post;
+ if (filter == NULL) {
+ return NULL;
}
filter = talloc_asprintf_append_buffer(filter, "(DomainGuid=%s)",
- ldap_encode_ndr_GUID(state, &guid));
- if (tevent_req_nomem(filter, req)) {
- goto post;
+ ldap_encode_ndr_GUID(mem_ctx, &guid));
+ if (filter == NULL) {
+ return NULL;
}
}
filter = talloc_asprintf_append_buffer(filter, ")");
+
+ return filter;
+}
+
+static void cldap_netlogon_state_done(struct tevent_req *subreq);
+/*
+ queue a cldap netlogon for send
+*/
+struct tevent_req *cldap_netlogon_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct cldap_socket *cldap,
+ const struct cldap_netlogon *io)
+{
+ struct tevent_req *req, *subreq;
+ struct cldap_netlogon_state *state;
+ char *filter;
+ static const char * const attr[] = { "NetLogon", NULL };
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct cldap_netlogon_state);
+ if (!req) {
+ return NULL;
+ }
+
+ filter = cldap_netlogon_create_filter(state, io);
if (tevent_req_nomem(filter, req)) {
goto post;
}
diff --git a/libcli/cldap/cldap.h b/libcli/cldap/cldap.h
index 0bc9454f80f..cd76fee60f3 100644
--- a/libcli/cldap/cldap.h
+++ b/libcli/cldap/cldap.h
@@ -123,6 +123,8 @@ NTSTATUS cldap_netlogon_recv(struct tevent_req *req,
NTSTATUS cldap_netlogon(struct cldap_socket *cldap,
TALLOC_CTX *mem_ctx,
struct cldap_netlogon *io);
+char *cldap_netlogon_create_filter(TALLOC_CTX *mem_ctx,
+ const struct cldap_netlogon *io);
NTSTATUS cldap_netlogon_reply(struct cldap_socket *cldap,
uint32_t message_id,