diff options
author | Günther Deschner <gd@samba.org> | 2008-06-02 17:31:00 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2008-06-03 01:27:45 +0200 |
commit | 2997e2868cbff93e6ff3b1f59a8997871c946ca1 (patch) | |
tree | e8456ef7dbb3c1d90aa9868dc93c798057ac82d4 /source3/lib | |
parent | 31c185011fc70038f1f7fad3049f782bdba49688 (diff) | |
download | samba-2997e2868cbff93e6ff3b1f59a8997871c946ca1.tar.gz samba-2997e2868cbff93e6ff3b1f59a8997871c946ca1.tar.bz2 samba-2997e2868cbff93e6ff3b1f59a8997871c946ca1.zip |
netapi: use libnetapi_samr_open_domain().
Guenther
(This used to be commit b07445e86f43d6e9e45b7c502ab7998bca4db14f)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/netapi/group.c | 412 | ||||
-rw-r--r-- | source3/lib/netapi/user.c | 282 |
2 files changed, 87 insertions, 607 deletions
diff --git a/source3/lib/netapi/group.c b/source3/lib/netapi/group.c index d46d2e6135..7f905f0185 100644 --- a/source3/lib/netapi/group.c +++ b/source3/lib/netapi/group.c @@ -34,16 +34,11 @@ WERROR NetGroupAdd_r(struct libnetapi_ctx *ctx, struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; - uint32_t resume_handle = 0; - uint32_t num_entries = 0; POLICY_HND connect_handle, domain_handle, group_handle; - struct samr_SamArray *sam = NULL; - const char *domain_name = NULL; - struct lsa_String lsa_domain_name, lsa_group_name; + struct lsa_String lsa_group_name; struct dom_sid2 *domain_sid = NULL; uint32_t rid = 0; - bool domain_found = true; - int i; + struct GROUP_INFO_0 *info0; struct GROUP_INFO_1 *info1; struct GROUP_INFO_2 *info2; @@ -86,60 +81,14 @@ WERROR NetGroupAdd_r(struct libnetapi_ctx *ctx, goto done; } - status = rpccli_try_samr_connects(pipe_cli, ctx, - SAMR_ACCESS_ENUM_DOMAINS | - SAMR_ACCESS_OPEN_DOMAIN, - &connect_handle); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_EnumDomains(pipe_cli, ctx, - &connect_handle, - &resume_handle, - &sam, - 0xffffffff, - &num_entries); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - for (i=0; i<num_entries; i++) { - - domain_name = sam->entries[i].name.string; - - if (strequal(domain_name, builtin_domain_name())) { - continue; - } - - domain_found = true; - break; - } - - if (!domain_found) { - werr = WERR_NO_SUCH_DOMAIN; - goto done; - } - - init_lsa_String(&lsa_domain_name, domain_name); - - status = rpccli_samr_LookupDomain(pipe_cli, ctx, - &connect_handle, - &lsa_domain_name, - &domain_sid); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_OpenDomain(pipe_cli, ctx, - &connect_handle, - SAMR_DOMAIN_ACCESS_CREATE_GROUP | - SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, - domain_sid, - &domain_handle); + status = libnetapi_samr_open_domain(ctx, pipe_cli, + SAMR_ACCESS_ENUM_DOMAINS | + SAMR_ACCESS_OPEN_DOMAIN, + SAMR_DOMAIN_ACCESS_CREATE_GROUP | + SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, + &connect_handle, + &domain_handle, + &domain_sid); if (!NT_STATUS_IS_OK(status)) { werr = ntstatus_to_werror(status); goto done; @@ -285,15 +234,10 @@ WERROR NetGroupDel_r(struct libnetapi_ctx *ctx, struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; - uint32_t resume_handle = 0; - uint32_t num_entries = 0; POLICY_HND connect_handle, domain_handle, group_handle; - struct samr_SamArray *sam = NULL; - const char *domain_name = NULL; - struct lsa_String lsa_domain_name, lsa_group_name; + struct lsa_String lsa_group_name; struct dom_sid2 *domain_sid = NULL; - bool domain_found = true; - int i; + int i = 0; struct samr_Ids rids; struct samr_Ids types; @@ -318,59 +262,13 @@ WERROR NetGroupDel_r(struct libnetapi_ctx *ctx, goto done; } - status = rpccli_try_samr_connects(pipe_cli, ctx, - SAMR_ACCESS_ENUM_DOMAINS | - SAMR_ACCESS_OPEN_DOMAIN, - &connect_handle); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_EnumDomains(pipe_cli, ctx, - &connect_handle, - &resume_handle, - &sam, - 0xffffffff, - &num_entries); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - for (i=0; i<num_entries; i++) { - - domain_name = sam->entries[i].name.string; - - if (strequal(domain_name, builtin_domain_name())) { - continue; - } - - domain_found = true; - break; - } - - if (!domain_found) { - werr = WERR_NO_SUCH_DOMAIN; - goto done; - } - - init_lsa_String(&lsa_domain_name, domain_name); - - status = rpccli_samr_LookupDomain(pipe_cli, ctx, - &connect_handle, - &lsa_domain_name, - &domain_sid); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_OpenDomain(pipe_cli, ctx, - &connect_handle, - SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, - domain_sid, - &domain_handle); + status = libnetapi_samr_open_domain(ctx, pipe_cli, + SAMR_ACCESS_ENUM_DOMAINS | + SAMR_ACCESS_OPEN_DOMAIN, + SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, + &connect_handle, + &domain_handle, + &domain_sid); if (!NT_STATUS_IS_OK(status)) { werr = ntstatus_to_werror(status); goto done; @@ -505,15 +403,9 @@ WERROR NetGroupSetInfo_r(struct libnetapi_ctx *ctx, struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; - uint32_t resume_handle = 0; - uint32_t num_entries = 0; POLICY_HND connect_handle, domain_handle, group_handle; - struct samr_SamArray *sam = NULL; - const char *domain_name = NULL; - struct lsa_String lsa_domain_name, lsa_group_name; + struct lsa_String lsa_group_name; struct dom_sid2 *domain_sid = NULL; - bool domain_found = true; - int i; struct samr_Ids rids; struct samr_Ids types; @@ -543,59 +435,13 @@ WERROR NetGroupSetInfo_r(struct libnetapi_ctx *ctx, goto done; } - status = rpccli_try_samr_connects(pipe_cli, ctx, - SAMR_ACCESS_ENUM_DOMAINS | - SAMR_ACCESS_OPEN_DOMAIN, - &connect_handle); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_EnumDomains(pipe_cli, ctx, - &connect_handle, - &resume_handle, - &sam, - 0xffffffff, - &num_entries); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - for (i=0; i<num_entries; i++) { - - domain_name = sam->entries[i].name.string; - - if (strequal(domain_name, builtin_domain_name())) { - continue; - } - - domain_found = true; - break; - } - - if (!domain_found) { - werr = WERR_NO_SUCH_DOMAIN; - goto done; - } - - init_lsa_String(&lsa_domain_name, domain_name); - - status = rpccli_samr_LookupDomain(pipe_cli, ctx, - &connect_handle, - &lsa_domain_name, - &domain_sid); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_OpenDomain(pipe_cli, ctx, - &connect_handle, - SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, - domain_sid, - &domain_handle); + status = libnetapi_samr_open_domain(ctx, pipe_cli, + SAMR_ACCESS_ENUM_DOMAINS | + SAMR_ACCESS_OPEN_DOMAIN, + SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, + &connect_handle, + &domain_handle, + &domain_sid); if (!NT_STATUS_IS_OK(status)) { werr = ntstatus_to_werror(status); goto done; @@ -805,15 +651,9 @@ WERROR NetGroupGetInfo_r(struct libnetapi_ctx *ctx, struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; - uint32_t resume_handle = 0; - uint32_t num_entries = 0; POLICY_HND connect_handle, domain_handle, group_handle; - struct samr_SamArray *sam = NULL; - const char *domain_name = NULL; - struct lsa_String lsa_domain_name, lsa_group_name; + struct lsa_String lsa_group_name; struct dom_sid2 *domain_sid = NULL; - bool domain_found = true; - int i; struct samr_Ids rids; struct samr_Ids types; @@ -837,59 +677,13 @@ WERROR NetGroupGetInfo_r(struct libnetapi_ctx *ctx, goto done; } - status = rpccli_try_samr_connects(pipe_cli, ctx, - SAMR_ACCESS_ENUM_DOMAINS | - SAMR_ACCESS_OPEN_DOMAIN, - &connect_handle); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_EnumDomains(pipe_cli, ctx, - &connect_handle, - &resume_handle, - &sam, - 0xffffffff, - &num_entries); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - for (i=0; i<num_entries; i++) { - - domain_name = sam->entries[i].name.string; - - if (strequal(domain_name, builtin_domain_name())) { - continue; - } - - domain_found = true; - break; - } - - if (!domain_found) { - werr = WERR_NO_SUCH_DOMAIN; - goto done; - } - - init_lsa_String(&lsa_domain_name, domain_name); - - status = rpccli_samr_LookupDomain(pipe_cli, ctx, - &connect_handle, - &lsa_domain_name, - &domain_sid); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_OpenDomain(pipe_cli, ctx, - &connect_handle, - SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, - domain_sid, - &domain_handle); + status = libnetapi_samr_open_domain(ctx, pipe_cli, + SAMR_ACCESS_ENUM_DOMAINS | + SAMR_ACCESS_OPEN_DOMAIN, + SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, + &connect_handle, + &domain_handle, + &domain_sid); if (!NT_STATUS_IS_OK(status)) { werr = ntstatus_to_werror(status); goto done; @@ -975,15 +769,9 @@ WERROR NetGroupAddUser_r(struct libnetapi_ctx *ctx, struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; - uint32_t resume_handle = 0; - uint32_t num_entries = 0; POLICY_HND connect_handle, domain_handle, group_handle; - struct samr_SamArray *sam = NULL; - const char *domain_name = NULL; - struct lsa_String lsa_domain_name, lsa_group_name, lsa_user_name; + struct lsa_String lsa_group_name, lsa_user_name; struct dom_sid2 *domain_sid = NULL; - bool domain_found = true; - int i; struct samr_Ids rids; struct samr_Ids types; @@ -1006,59 +794,13 @@ WERROR NetGroupAddUser_r(struct libnetapi_ctx *ctx, goto done; } - status = rpccli_try_samr_connects(pipe_cli, ctx, - SAMR_ACCESS_ENUM_DOMAINS | - SAMR_ACCESS_OPEN_DOMAIN, - &connect_handle); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_EnumDomains(pipe_cli, ctx, - &connect_handle, - &resume_handle, - &sam, - 0xffffffff, - &num_entries); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - for (i=0; i<num_entries; i++) { - - domain_name = sam->entries[i].name.string; - - if (strequal(domain_name, builtin_domain_name())) { - continue; - } - - domain_found = true; - break; - } - - if (!domain_found) { - werr = WERR_NO_SUCH_DOMAIN; - goto done; - } - - init_lsa_String(&lsa_domain_name, domain_name); - - status = rpccli_samr_LookupDomain(pipe_cli, ctx, - &connect_handle, - &lsa_domain_name, - &domain_sid); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_OpenDomain(pipe_cli, ctx, - &connect_handle, - SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, - domain_sid, - &domain_handle); + status = libnetapi_samr_open_domain(ctx, pipe_cli, + SAMR_ACCESS_ENUM_DOMAINS | + SAMR_ACCESS_OPEN_DOMAIN, + SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, + &connect_handle, + &domain_handle, + &domain_sid); if (!NT_STATUS_IS_OK(status)) { werr = ntstatus_to_werror(status); goto done; @@ -1158,15 +900,9 @@ WERROR NetGroupDelUser_r(struct libnetapi_ctx *ctx, struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; - uint32_t resume_handle = 0; - uint32_t num_entries = 0; POLICY_HND connect_handle, domain_handle, group_handle; - struct samr_SamArray *sam = NULL; - const char *domain_name = NULL; - struct lsa_String lsa_domain_name, lsa_group_name, lsa_user_name; + struct lsa_String lsa_group_name, lsa_user_name; struct dom_sid2 *domain_sid = NULL; - bool domain_found = true; - int i; struct samr_Ids rids; struct samr_Ids types; @@ -1189,59 +925,13 @@ WERROR NetGroupDelUser_r(struct libnetapi_ctx *ctx, goto done; } - status = rpccli_try_samr_connects(pipe_cli, ctx, - SAMR_ACCESS_ENUM_DOMAINS | - SAMR_ACCESS_OPEN_DOMAIN, - &connect_handle); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_EnumDomains(pipe_cli, ctx, - &connect_handle, - &resume_handle, - &sam, - 0xffffffff, - &num_entries); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - for (i=0; i<num_entries; i++) { - - domain_name = sam->entries[i].name.string; - - if (strequal(domain_name, builtin_domain_name())) { - continue; - } - - domain_found = true; - break; - } - - if (!domain_found) { - werr = WERR_NO_SUCH_DOMAIN; - goto done; - } - - init_lsa_String(&lsa_domain_name, domain_name); - - status = rpccli_samr_LookupDomain(pipe_cli, ctx, - &connect_handle, - &lsa_domain_name, - &domain_sid); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_OpenDomain(pipe_cli, ctx, - &connect_handle, - SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, - domain_sid, - &domain_handle); + status = libnetapi_samr_open_domain(ctx, pipe_cli, + SAMR_ACCESS_ENUM_DOMAINS | + SAMR_ACCESS_OPEN_DOMAIN, + SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, + &connect_handle, + &domain_handle, + &domain_sid); if (!NT_STATUS_IS_OK(status)) { werr = ntstatus_to_werror(status); goto done; diff --git a/source3/lib/netapi/user.c b/source3/lib/netapi/user.c index f2dc785a36..de4f9164ce 100644 --- a/source3/lib/netapi/user.c +++ b/source3/lib/netapi/user.c @@ -135,20 +135,14 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx, struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; - uint32_t resume_handle = 0; - uint32_t num_entries = 0; POLICY_HND connect_handle, domain_handle, user_handle; - struct samr_SamArray *sam = NULL; - const char *domain_name = NULL; - struct lsa_String lsa_domain_name, lsa_account_name; + struct lsa_String lsa_account_name; struct dom_sid2 *domain_sid = NULL; struct samr_UserInfo25 info25; union samr_UserInfo *user_info = NULL; struct samr_PwInfo pw_info; uint32_t access_granted = 0; uint32_t rid = 0; - bool domain_found = true; - int i; struct USER_INFO_1 *info1; ZERO_STRUCT(connect_handle); @@ -181,61 +175,15 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx, goto done; } - status = rpccli_try_samr_connects(pipe_cli, ctx, - SAMR_ACCESS_ENUM_DOMAINS | - SAMR_ACCESS_OPEN_DOMAIN, - &connect_handle); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_EnumDomains(pipe_cli, ctx, - &connect_handle, - &resume_handle, - &sam, - 0xffffffff, - &num_entries); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - for (i=0; i<num_entries; i++) { - - domain_name = sam->entries[i].name.string; - - if (strequal(domain_name, builtin_domain_name())) { - continue; - } - - domain_found = true; - break; - } - - if (!domain_found) { - werr = WERR_NO_SUCH_DOMAIN; - goto done; - } - - init_lsa_String(&lsa_domain_name, domain_name); - - status = rpccli_samr_LookupDomain(pipe_cli, ctx, - &connect_handle, - &lsa_domain_name, - &domain_sid); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_OpenDomain(pipe_cli, ctx, - &connect_handle, - SAMR_DOMAIN_ACCESS_LOOKUP_INFO_1 | - SAMR_DOMAIN_ACCESS_CREATE_USER | - SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, - domain_sid, - &domain_handle); + status = libnetapi_samr_open_domain(ctx, pipe_cli, + SAMR_ACCESS_ENUM_DOMAINS | + SAMR_ACCESS_OPEN_DOMAIN, + SAMR_DOMAIN_ACCESS_LOOKUP_INFO_1 | + SAMR_DOMAIN_ACCESS_CREATE_USER | + SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, + &connect_handle, + &domain_handle, + &domain_sid); if (!NT_STATUS_IS_OK(status)) { werr = ntstatus_to_werror(status); goto done; @@ -356,17 +304,11 @@ WERROR NetUserDel_r(struct libnetapi_ctx *ctx, struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; - uint32_t resume_handle = 0; - uint32_t num_entries = 0; POLICY_HND connect_handle, builtin_handle, domain_handle, user_handle; - struct samr_SamArray *sam = NULL; - const char *domain_name = NULL; - struct lsa_String lsa_domain_name, lsa_account_name; + struct lsa_String lsa_account_name; struct samr_Ids user_rids, name_types; struct dom_sid2 *domain_sid = NULL; struct dom_sid2 user_sid; - bool domain_found = true; - int i; ZERO_STRUCT(connect_handle); ZERO_STRUCT(builtin_handle); @@ -383,59 +325,13 @@ WERROR NetUserDel_r(struct libnetapi_ctx *ctx, goto done; } - status = rpccli_try_samr_connects(pipe_cli, ctx, - SAMR_ACCESS_ENUM_DOMAINS | - SAMR_ACCESS_OPEN_DOMAIN, - &connect_handle); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_EnumDomains(pipe_cli, ctx, - &connect_handle, - &resume_handle, - &sam, - 0xffffffff, - &num_entries); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - for (i=0; i<num_entries; i++) { - - domain_name = sam->entries[i].name.string; - - if (strequal(domain_name, builtin_domain_name())) { - continue; - } - - domain_found = true; - break; - } - - if (!domain_found) { - werr = WERR_NO_SUCH_DOMAIN; - goto done; - } - - init_lsa_String(&lsa_domain_name, domain_name); - - status = rpccli_samr_LookupDomain(pipe_cli, ctx, - &connect_handle, - &lsa_domain_name, - &domain_sid); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_OpenDomain(pipe_cli, ctx, - &connect_handle, - SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, - domain_sid, - &domain_handle); + status = libnetapi_samr_open_domain(ctx, pipe_cli, + SAMR_ACCESS_ENUM_DOMAINS | + SAMR_ACCESS_OPEN_DOMAIN, + SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, + &connect_handle, + &domain_handle, + &domain_sid); if (!NT_STATUS_IS_OK(status)) { werr = ntstatus_to_werror(status); goto done; @@ -574,12 +470,6 @@ WERROR NetUserEnum_r(struct libnetapi_ctx *ctx, struct dom_sid2 *domain_sid = NULL; struct policy_handle domain_handle; struct samr_SamArray *sam = NULL; - uint32_t num_entries = 0; - int i; - const char *domain_name = NULL; - bool domain_found = true; - uint32_t dom_resume_handle = 0; - struct lsa_String lsa_domain_name; NTSTATUS status; WERROR werr; @@ -611,62 +501,15 @@ WERROR NetUserEnum_r(struct libnetapi_ctx *ctx, goto done; } - status = rpccli_try_samr_connects(pipe_cli, ctx, - SAMR_ACCESS_OPEN_DOMAIN | - SAMR_ACCESS_ENUM_DOMAINS, - &connect_handle); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_EnumDomains(pipe_cli, ctx, - &connect_handle, - &dom_resume_handle, - &sam, - 0xffffffff, - &num_entries); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - for (i=0; i<num_entries; i++) { - - domain_name = sam->entries[i].name.string; - - if (strequal(domain_name, builtin_domain_name())) { - continue; - } - - domain_found = true; - break; - } - - if (!domain_found) { - werr = WERR_NO_SUCH_DOMAIN; - goto done; - } - - init_lsa_String(&lsa_domain_name, domain_name); - - status = rpccli_samr_LookupDomain(pipe_cli, ctx, - &connect_handle, - &lsa_domain_name, - &domain_sid); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_OpenDomain(pipe_cli, - ctx, - &connect_handle, - SAMR_DOMAIN_ACCESS_LOOKUP_INFO_2 | - SAMR_DOMAIN_ACCESS_ENUM_ACCOUNTS | - SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, - domain_sid, - &domain_handle); + status = libnetapi_samr_open_domain(ctx, pipe_cli, + SAMR_ACCESS_ENUM_DOMAINS | + SAMR_ACCESS_OPEN_DOMAIN, + SAMR_DOMAIN_ACCESS_LOOKUP_INFO_2 | + SAMR_DOMAIN_ACCESS_ENUM_ACCOUNTS | + SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, + &connect_handle, + &domain_handle, + &domain_sid); if (!NT_STATUS_IS_OK(status)) { werr = ntstatus_to_werror(status); goto done; @@ -886,13 +729,6 @@ WERROR NetQueryDisplayInformation_r(struct libnetapi_ctx *ctx, struct dom_sid2 *domain_sid = NULL; struct policy_handle domain_handle; union samr_DispInfo info; - struct samr_SamArray *sam = NULL; - uint32_t num_entries = 0; - int i; - const char *domain_name = NULL; - bool domain_found = true; - uint32_t dom_resume_handle = 0; - struct lsa_String lsa_domain_name; uint32_t total_size = 0; uint32_t returned_size = 0; @@ -922,61 +758,15 @@ WERROR NetQueryDisplayInformation_r(struct libnetapi_ctx *ctx, goto done; } - status = rpccli_try_samr_connects(pipe_cli, ctx, - SAMR_ACCESS_OPEN_DOMAIN | - SAMR_ACCESS_ENUM_DOMAINS, - &connect_handle); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_EnumDomains(pipe_cli, ctx, - &connect_handle, - &dom_resume_handle, - &sam, - 0xffffffff, - &num_entries); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - for (i=0; i<num_entries; i++) { - - domain_name = sam->entries[i].name.string; - - if (strequal(domain_name, builtin_domain_name())) { - continue; - } - - domain_found = true; - break; - } - - if (!domain_found) { - werr = WERR_NO_SUCH_DOMAIN; - goto done; - } - - init_lsa_String(&lsa_domain_name, domain_name); - - status = rpccli_samr_LookupDomain(pipe_cli, ctx, - &connect_handle, - &lsa_domain_name, - &domain_sid); - if (!NT_STATUS_IS_OK(status)) { - werr = ntstatus_to_werror(status); - goto done; - } - - status = rpccli_samr_OpenDomain(pipe_cli, - ctx, - &connect_handle, - SAMR_DOMAIN_ACCESS_ENUM_ACCOUNTS | - SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, - domain_sid, - &domain_handle); + status = libnetapi_samr_open_domain(ctx, pipe_cli, + SAMR_ACCESS_ENUM_DOMAINS | + SAMR_ACCESS_OPEN_DOMAIN, + SAMR_DOMAIN_ACCESS_LOOKUP_INFO_2 | + SAMR_DOMAIN_ACCESS_ENUM_ACCOUNTS | + SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT, + &connect_handle, + &domain_handle, + &domain_sid); if (!NT_STATUS_IS_OK(status)) { werr = ntstatus_to_werror(status); goto done; |