summaryrefslogtreecommitdiff
path: root/source4/librpc/ndr
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-11-09 00:58:40 +0000
committerAndrew Tridgell <tridge@samba.org>2003-11-09 00:58:40 +0000
commitcff32d6b0ae3b8f17973f544d8be891704437915 (patch)
treee1bf089b426305deb478750336cef08906c9bf93 /source4/librpc/ndr
parent2430e941d748beebd1297c83d176982e7ff89be7 (diff)
downloadsamba-cff32d6b0ae3b8f17973f544d8be891704437915.tar.gz
samba-cff32d6b0ae3b8f17973f544d8be891704437915.tar.bz2
samba-cff32d6b0ae3b8f17973f544d8be891704437915.zip
added idl, generated code and test code for lsa_LookupSids
(This used to be commit afa1ff5f08fceba3d34b4e0965fe7e0c0143ede9)
Diffstat (limited to 'source4/librpc/ndr')
-rw-r--r--source4/librpc/ndr/ndr.c11
-rw-r--r--source4/librpc/ndr/ndr_basic.c2
-rw-r--r--source4/librpc/ndr/ndr_lsa.c199
-rw-r--r--source4/librpc/ndr/ndr_lsa.h46
4 files changed, 256 insertions, 2 deletions
diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c
index dabe75d5ac..2413e7322d 100644
--- a/source4/librpc/ndr/ndr.c
+++ b/source4/librpc/ndr/ndr.c
@@ -196,10 +196,19 @@ NTSTATUS ndr_push_array(struct ndr_push *ndr, int ndr_flags, void *base,
int i;
char *p = base;
NDR_CHECK(ndr_push_uint32(ndr, count));
+ if (!(ndr_flags & NDR_SCALARS)) goto buffers;
for (i=0;i<count;i++) {
- NDR_CHECK(push_fn(ndr, ndr_flags, p));
+ NDR_CHECK(push_fn(ndr, NDR_SCALARS, p));
p += elsize;
}
+ if (!(ndr_flags & NDR_BUFFERS)) goto done;
+buffers:
+ p = base;
+ for (i=0;i<count;i++) {
+ NDR_CHECK(push_fn(ndr, NDR_BUFFERS, p));
+ p += elsize;
+ }
+done:
return NT_STATUS_OK;
}
diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c
index 21bd36963c..3e6d0b30e6 100644
--- a/source4/librpc/ndr/ndr_basic.c
+++ b/source4/librpc/ndr/ndr_basic.c
@@ -257,7 +257,7 @@ NTSTATUS ndr_pull_unistr(struct ndr_pull *ndr, const char **s)
return NT_STATUS_INVALID_PARAMETER;
}
NDR_ALLOC_N(ndr, ws, (len1+1)*2);
- NDR_CHECK(ndr_pull_bytes(ndr, ws, len1*2));
+ NDR_CHECK(ndr_pull_bytes(ndr, ws, len2*2));
SSVAL(ws, len1*2, 0);
SSVAL(ws, len2*2, 0);
pull_ucs2_talloc(ndr->mem_ctx, &as, (const smb_ucs2_t *)ws);
diff --git a/source4/librpc/ndr/ndr_lsa.c b/source4/librpc/ndr/ndr_lsa.c
index 533e895006..8e42b3786b 100644
--- a/source4/librpc/ndr/ndr_lsa.c
+++ b/source4/librpc/ndr/ndr_lsa.c
@@ -258,3 +258,202 @@ NTSTATUS ndr_pull_lsa_EnumSids(struct ndr_pull *ndr, struct lsa_EnumSids *r)
return NT_STATUS_OK;
}
+static NTSTATUS ndr_push_lsa_Name(struct ndr_push *ndr, int ndr_flags, struct lsa_Name *r)
+{
+ if (!(ndr_flags & NDR_SCALARS)) goto buffers;
+ NDR_CHECK(ndr_push_uint16(ndr, r->name_len));
+ NDR_CHECK(ndr_push_uint16(ndr, r->name_size));
+ NDR_CHECK(ndr_push_ptr(ndr, r->name));
+buffers:
+ if (!(ndr_flags & NDR_BUFFERS)) goto done;
+ if (r->name) {
+ NDR_CHECK(ndr_push_unistr(ndr, r->name));
+ }
+done:
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS ndr_pull_lsa_Name(struct ndr_pull *ndr, int ndr_flags, struct lsa_Name *r)
+{
+ uint32 _ptr_name;
+ if (!(ndr_flags & NDR_SCALARS)) goto buffers;
+ NDR_CHECK(ndr_pull_uint16(ndr, &r->name_len));
+ NDR_CHECK(ndr_pull_uint16(ndr, &r->name_size));
+ NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_name));
+ if (_ptr_name) {
+ NDR_ALLOC(ndr, r->name);
+ } else {
+ r->name = NULL;
+ }
+buffers:
+ if (!(ndr_flags & NDR_BUFFERS)) goto done;
+ if (r->name) {
+ NDR_CHECK(ndr_pull_unistr(ndr, &r->name));
+ }
+done:
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS ndr_push_lsa_TranslatedName(struct ndr_push *ndr, int ndr_flags, struct lsa_TranslatedName *r)
+{
+ if (!(ndr_flags & NDR_SCALARS)) goto buffers;
+ NDR_CHECK(ndr_push_uint16(ndr, r->sid_type));
+ NDR_CHECK(ndr_push_lsa_Name(ndr, NDR_SCALARS, &r->name));
+ NDR_CHECK(ndr_push_uint32(ndr, r->sid_index));
+buffers:
+ if (!(ndr_flags & NDR_BUFFERS)) goto done;
+ NDR_CHECK(ndr_push_lsa_Name(ndr, ndr_flags, &r->name));
+done:
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS ndr_pull_lsa_TranslatedName(struct ndr_pull *ndr, int ndr_flags, struct lsa_TranslatedName *r)
+{
+ if (!(ndr_flags & NDR_SCALARS)) goto buffers;
+ NDR_CHECK(ndr_pull_uint16(ndr, &r->sid_type));
+ NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_SCALARS, &r->name));
+ NDR_CHECK(ndr_pull_uint32(ndr, &r->sid_index));
+buffers:
+ if (!(ndr_flags & NDR_BUFFERS)) goto done;
+ NDR_CHECK(ndr_pull_lsa_Name(ndr, ndr_flags, &r->name));
+done:
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS ndr_push_lsa_TransNameArray(struct ndr_push *ndr, int ndr_flags, struct lsa_TransNameArray *r)
+{
+ if (!(ndr_flags & NDR_SCALARS)) goto buffers;
+ NDR_CHECK(ndr_push_uint32(ndr, r->count));
+ NDR_CHECK(ndr_push_ptr(ndr, r->names));
+buffers:
+ if (!(ndr_flags & NDR_BUFFERS)) goto done;
+ if (r->names) {
+ NDR_CHECK(ndr_push_array(ndr, ndr_flags, r->names, sizeof(r->names[0]), r->count, (ndr_push_flags_fn_t)ndr_push_lsa_TranslatedName));
+ }
+done:
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS ndr_pull_lsa_TransNameArray(struct ndr_pull *ndr, int ndr_flags, struct lsa_TransNameArray *r)
+{
+ uint32 _ptr_names;
+ if (!(ndr_flags & NDR_SCALARS)) goto buffers;
+ NDR_CHECK(ndr_pull_uint32(ndr, &r->count));
+ NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_names));
+ if (_ptr_names) {
+ NDR_ALLOC(ndr, r->names);
+ } else {
+ r->names = NULL;
+ }
+buffers:
+ if (!(ndr_flags & NDR_BUFFERS)) goto done;
+ if (r->names) {
+ NDR_CHECK(ndr_pull_array(ndr, ndr_flags, (void **)&r->names, sizeof(r->names[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_lsa_TranslatedName));
+ }
+done:
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS ndr_push_lsa_TrustInformation(struct ndr_push *ndr, int ndr_flags, struct lsa_TrustInformation *r)
+{
+ if (!(ndr_flags & NDR_SCALARS)) goto buffers;
+ NDR_CHECK(ndr_push_lsa_Name(ndr, NDR_SCALARS, &r->name));
+ NDR_CHECK(ndr_push_ptr(ndr, r->sid));
+buffers:
+ if (!(ndr_flags & NDR_BUFFERS)) goto done;
+ NDR_CHECK(ndr_push_lsa_Name(ndr, ndr_flags, &r->name));
+ if (r->sid) {
+ NDR_CHECK(ndr_push_dom_sid2(ndr, r->sid));
+ }
+done:
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS ndr_pull_lsa_TrustInformation(struct ndr_pull *ndr, int ndr_flags, struct lsa_TrustInformation *r)
+{
+ uint32 _ptr_sid;
+ if (!(ndr_flags & NDR_SCALARS)) goto buffers;
+ NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_SCALARS, &r->name));
+ NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_sid));
+ if (_ptr_sid) {
+ NDR_ALLOC(ndr, r->sid);
+ } else {
+ r->sid = NULL;
+ }
+buffers:
+ if (!(ndr_flags & NDR_BUFFERS)) goto done;
+ NDR_CHECK(ndr_pull_lsa_Name(ndr, ndr_flags, &r->name));
+ if (r->sid) {
+ NDR_CHECK(ndr_pull_dom_sid2(ndr, r->sid));
+ }
+done:
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS ndr_push_lsa_RefDomainList(struct ndr_push *ndr, int ndr_flags, struct lsa_RefDomainList *r)
+{
+ if (!(ndr_flags & NDR_SCALARS)) goto buffers;
+ NDR_CHECK(ndr_push_uint32(ndr, r->count));
+ NDR_CHECK(ndr_push_ptr(ndr, r->domains));
+ NDR_CHECK(ndr_push_uint32(ndr, r->max_count));
+buffers:
+ if (!(ndr_flags & NDR_BUFFERS)) goto done;
+ if (r->domains) {
+ NDR_CHECK(ndr_push_array(ndr, ndr_flags, r->domains, sizeof(r->domains[0]), r->count, (ndr_push_flags_fn_t)ndr_push_lsa_TrustInformation));
+ }
+done:
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS ndr_pull_lsa_RefDomainList(struct ndr_pull *ndr, int ndr_flags, struct lsa_RefDomainList *r)
+{
+ uint32 _ptr_domains;
+ if (!(ndr_flags & NDR_SCALARS)) goto buffers;
+ NDR_CHECK(ndr_pull_uint32(ndr, &r->count));
+ NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_domains));
+ if (_ptr_domains) {
+ NDR_ALLOC(ndr, r->domains);
+ } else {
+ r->domains = NULL;
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, &r->max_count));
+buffers:
+ if (!(ndr_flags & NDR_BUFFERS)) goto done;
+ if (r->domains) {
+ NDR_CHECK(ndr_pull_array(ndr, ndr_flags, (void **)&r->domains, sizeof(r->domains[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_lsa_TrustInformation));
+ }
+done:
+ return NT_STATUS_OK;
+}
+
+NTSTATUS ndr_push_lsa_LookupSids(struct ndr_push *ndr, struct lsa_LookupSids *r)
+{
+ NDR_CHECK(ndr_push_policy_handle(ndr, r->in.handle));
+ NDR_CHECK(ndr_push_lsa_SidArray(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.sids));
+ NDR_CHECK(ndr_push_lsa_TransNameArray(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.names));
+ NDR_CHECK(ndr_push_uint16(ndr, r->in.level));
+ NDR_CHECK(ndr_push_uint32(ndr, *r->in.count));
+
+ return NT_STATUS_OK;
+}
+
+NTSTATUS ndr_pull_lsa_LookupSids(struct ndr_pull *ndr, struct lsa_LookupSids *r)
+{
+ uint32 _ptr_domains;
+ NDR_ALLOC(ndr, r->out.domains);
+ NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_domains));
+ if (_ptr_domains) {
+ NDR_ALLOC(ndr, r->out.domains);
+ } else {
+ r->out.domains = NULL;
+ }
+ if (r->out.domains) {
+ NDR_CHECK(ndr_pull_lsa_RefDomainList(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.domains));
+ }
+ NDR_CHECK(ndr_pull_lsa_TransNameArray(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.names));
+ NDR_CHECK(ndr_pull_uint32(ndr, r->out.count));
+ NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result));
+
+ return NT_STATUS_OK;
+}
+
diff --git a/source4/librpc/ndr/ndr_lsa.h b/source4/librpc/ndr/ndr_lsa.h
index c19a884536..ef70c5d073 100644
--- a/source4/librpc/ndr/ndr_lsa.h
+++ b/source4/librpc/ndr/ndr_lsa.h
@@ -66,3 +66,49 @@ struct lsa_EnumSids {
};
+struct lsa_Name {
+ uint16 name_len;
+ uint16 name_size;
+ const char *name;
+};
+
+struct lsa_TranslatedName {
+ uint16 sid_type;
+ struct lsa_Name name;
+ uint32 sid_index;
+};
+
+struct lsa_TransNameArray {
+ uint32 count;
+ struct lsa_TranslatedName *names;
+};
+
+struct lsa_TrustInformation {
+ struct lsa_Name name;
+ struct dom_sid2 *sid;
+};
+
+struct lsa_RefDomainList {
+ uint32 count;
+ struct lsa_TrustInformation *domains;
+ uint32 max_count;
+};
+
+struct lsa_LookupSids {
+ struct {
+ struct policy_handle *handle;
+ struct lsa_SidArray *sids;
+ struct lsa_TransNameArray *names;
+ uint16 level;
+ uint32 *count;
+ } in;
+
+ struct {
+ struct lsa_RefDomainList *domains;
+ struct lsa_TransNameArray *names;
+ uint32 *count;
+ NTSTATUS result;
+ } out;
+
+};
+