netapi: add libnetapi_samr_lookup_and_open_alias().
authorGünther Deschner <gd@samba.org>
Mon, 2 Jun 2008 22:41:36 +0000 (00:41 +0200)
committerGünther Deschner <gd@samba.org>
Mon, 2 Jun 2008 23:27:50 +0000 (01:27 +0200)
Guenther
(This used to be commit 890d63f31c0ff3931b8efb627c3a375850a59a9a)

source3/lib/netapi/localgroup.c

index a505abdf5b5d84f9c455e140d16bfd917686c511..07adf7c6a6fe5780f10913714117d0e2706643ce 100644 (file)
 #include "lib/netapi/netapi_private.h"
 #include "lib/netapi/libnetapi.h"
 
+static WERROR libnetapi_samr_lookup_and_open_alias(TALLOC_CTX *mem_ctx,
+                                                  struct rpc_pipe_client *pipe_cli,
+                                                  struct policy_handle *domain_handle,
+                                                  struct lsa_String *lsa_account_name,
+                                                  uint32_t access_rights,
+                                                  struct policy_handle *alias_handle)
+{
+       NTSTATUS status;
+       WERROR werr;
+       struct samr_Ids user_rids, name_types;
+
+       status = rpccli_samr_LookupNames(pipe_cli, mem_ctx,
+                                        domain_handle,
+                                        1,
+                                        lsa_account_name,
+                                        &user_rids,
+                                        &name_types);
+       if (!NT_STATUS_IS_OK(status)) {
+               werr = ntstatus_to_werror(status);
+               goto done;
+       }
+
+       switch (name_types.ids[0]) {
+               case SID_NAME_ALIAS:
+               case SID_NAME_WKN_GRP:
+                       break;
+               default:
+                       return WERR_INVALID_DATATYPE;
+       }
+
+       status = rpccli_samr_OpenAlias(pipe_cli, mem_ctx,
+                                      domain_handle,
+                                      access_rights,
+                                      user_rids.ids[0],
+                                      alias_handle);
+       if (NT_STATUS_IS_OK(status)) {
+               werr = ntstatus_to_werror(status);
+               goto done;
+       }
+
+       werr = WERR_OK;
+
+ done:
+       return werr;
+}
+
 /****************************************************************
 ****************************************************************/