2 Unix SMB/CIFS mplementation.
4 wrap/unwrap NDR encoded elements for ldap calls
6 Copyright (C) Andrew Tridgell 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "libcli/ldap/ldap.h"
25 #include "librpc/gen_ndr/ndr_security.h"
26 #include "librpc/gen_ndr/ndr_misc.h"
29 encode a NDR uint32 as a ldap filter element
31 char *ldap_encode_ndr_uint32(TALLOC_CTX *mem_ctx, uint32_t value)
38 return ldb_binary_encode(mem_ctx, val);
42 encode a NDR dom_sid as a ldap filter element
44 char *ldap_encode_ndr_dom_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid)
49 status = ndr_push_struct_blob(&blob, mem_ctx, sid,
50 (ndr_push_flags_fn_t)ndr_push_dom_sid);
51 if (!NT_STATUS_IS_OK(status)) {
54 ret = ldb_binary_encode(mem_ctx, blob);
55 data_blob_free(&blob);
61 encode a NDR GUID as a ldap filter element
63 char *ldap_encode_ndr_GUID(TALLOC_CTX *mem_ctx, struct GUID *guid)
68 status = ndr_push_struct_blob(&blob, mem_ctx, guid,
69 (ndr_push_flags_fn_t)ndr_push_GUID);
70 if (!NT_STATUS_IS_OK(status)) {
73 ret = ldb_binary_encode(mem_ctx, blob);
74 data_blob_free(&blob);
79 decode a NDR GUID from a ldap filter element
81 NTSTATUS ldap_decode_ndr_GUID(TALLOC_CTX *mem_ctx, struct ldb_val val, struct GUID *guid)
87 blob.length = val.length;
88 status = ndr_pull_struct_blob(&blob, mem_ctx, guid,
89 (ndr_pull_flags_fn_t)ndr_pull_GUID);
90 talloc_free(val.data);