svn commit: samba r9348 - in branches/SOC/SAMBA_3_0/source: include libmsrpc

skel at samba.org skel at samba.org
Wed Aug 17 03:48:42 GMT 2005


Author: skel
Date: 2005-08-17 03:48:41 +0000 (Wed, 17 Aug 2005)
New Revision: 9348

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9348

Log:
added cac_SamCreateAlias(), cac_SamOpenAlias(), cac_SamDeleteAlias(), cac_SamAddAliasMember()


Modified:
   branches/SOC/SAMBA_3_0/source/include/libmsrpc.h
   branches/SOC/SAMBA_3_0/source/libmsrpc/cac_samr.c


Changeset:
Modified: branches/SOC/SAMBA_3_0/source/include/libmsrpc.h
===================================================================
--- branches/SOC/SAMBA_3_0/source/include/libmsrpc.h	2005-08-17 03:30:45 UTC (rev 9347)
+++ branches/SOC/SAMBA_3_0/source/include/libmsrpc.h	2005-08-17 03:48:41 UTC (rev 9348)
@@ -1463,7 +1463,59 @@
 
 int cac_SamEnumAliases(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamEnumAliases *op);
 
+struct SamCreateAlias {
+   struct {
+      /**Open handle to the domain SAM*/
+      POLICY_HND *domain;
 
+      /**The name of the alias*/
+      char *name;
+   } in;
+
+   struct {
+      /**Handle to the group*/
+      POLICY_HND *alias_hnd;
+   } out;
+};
+
+/** @ingroup SAM_Functions
+ * Creates an alias. If the alias already exists it will not be opened*/
+int cac_SamCreateAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCreateAlias *op);
+
+struct SamOpenAlias {
+   struct {
+      /**Open handle to the domain SAM*/
+      POLICY_HND *domain;
+
+      /**Desired access to open the group with. See Generic access masks in include/smb.h*/
+      uint32 access;
+
+      /**rid of the alias*/
+      uint32 alias_rid;
+   } in;
+
+   struct {
+      /**Handle to the alias*/
+      POLICY_HND *alias_hnd;
+   } out;
+};
+
+int cac_SamOpenAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenAlias *op);
+
+int cac_SamDeleteAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *alias_hnd);
+
+struct SamAddAliasMember {
+   struct {
+      /**Open handle to a alias*/
+      POLICY_HND *alias_hnd;
+
+      /**SID of new member*/
+      DOM_SID *sid;
+   } in;
+};
+
+int cac_SamAddAliasMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamAddAliasMember *op);
+
 void cac_GetAuthDataFn(const char * pServer,
                  const char * pShare,
                  char * pWorkgroup,

Modified: branches/SOC/SAMBA_3_0/source/libmsrpc/cac_samr.c
===================================================================
--- branches/SOC/SAMBA_3_0/source/libmsrpc/cac_samr.c	2005-08-17 03:30:45 UTC (rev 9347)
+++ branches/SOC/SAMBA_3_0/source/libmsrpc/cac_samr.c	2005-08-17 03:48:41 UTC (rev 9348)
@@ -1124,3 +1124,153 @@
    return CAC_SUCCESS;
 }
 
+int cac_SamCreateAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamCreateAlias *op) {
+   SMBCSRV *srv = NULL;
+
+   POLICY_HND *als_hnd_out = NULL;
+
+   if(!hnd) 
+      return CAC_FAILURE;
+
+   if(!hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR]) {
+      hnd->status = NT_STATUS_INVALID_HANDLE;
+      return CAC_FAILURE;
+   }
+
+   if(!op || !op->in.name || op->in.name[0] == '\0' || !mem_ctx) {
+      hnd->status = NT_STATUS_INVALID_PARAMETER;
+      return CAC_FAILURE;
+   }
+
+   srv = cac_GetServer(hnd);
+   if(!srv) {
+      hnd->status = NT_STATUS_UNSUCCESSFUL;
+      return CAC_FAILURE;
+   }
+
+   srv->cli.pipe_idx = PI_SAMR;
+
+   als_hnd_out = talloc(mem_ctx, POLICY_HND);
+   if(!als_hnd_out) {
+      hnd->status = NT_STATUS_NO_MEMORY;
+      return CAC_FAILURE;
+   }
+
+   hnd->status = cli_samr_create_dom_alias( &(srv->cli), mem_ctx, op->in.domain, op->in.name, als_hnd_out);
+
+   if(!NT_STATUS_IS_OK(hnd->status))
+      return CAC_FAILURE;
+
+   op->out.alias_hnd = als_hnd_out;
+
+   return CAC_SUCCESS;
+
+}
+
+int cac_SamOpenAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamOpenAlias *op) {
+   SMBCSRV *srv = NULL;
+
+   POLICY_HND *als_hnd_out = NULL;
+
+   if(!hnd) 
+      return CAC_FAILURE;
+
+   if(!hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR]) {
+      hnd->status = NT_STATUS_INVALID_HANDLE;
+      return CAC_FAILURE;
+   }
+
+   if(!op || op->in.access == 0 || op->in.alias_rid == 0 || !mem_ctx) {
+      hnd->status = NT_STATUS_INVALID_PARAMETER;
+      return CAC_FAILURE;
+   }
+
+   srv = cac_GetServer(hnd);
+   if(!srv) {
+      hnd->status = NT_STATUS_UNSUCCESSFUL;
+      return CAC_FAILURE;
+   }
+
+   srv->cli.pipe_idx = PI_SAMR;
+
+   als_hnd_out = talloc(mem_ctx, POLICY_HND);
+   if(!als_hnd_out) {
+      hnd->status = NT_STATUS_NO_MEMORY;
+      return CAC_FAILURE;
+   }
+
+   hnd->status = cli_samr_open_alias( &(srv->cli), mem_ctx, op->in.domain, op->in.access, op->in.alias_rid, als_hnd_out);
+
+   if(!NT_STATUS_IS_OK(hnd->status))
+      return CAC_FAILURE;
+
+   op->out.alias_hnd = als_hnd_out;
+
+   return CAC_SUCCESS;
+}
+
+int cac_SamDeleteAlias(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *alias_hnd) {
+   SMBCSRV *srv = NULL;
+
+   if(!hnd) 
+      return CAC_FAILURE;
+
+   if(!hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR]) {
+      hnd->status = NT_STATUS_INVALID_HANDLE;
+      return CAC_FAILURE;
+   }
+
+   if(!alias_hnd || !mem_ctx) {
+      hnd->status = NT_STATUS_INVALID_PARAMETER;
+      return CAC_FAILURE;
+   }
+
+   srv = cac_GetServer(hnd);
+   if(!srv) {
+      hnd->status = NT_STATUS_UNSUCCESSFUL;
+      return CAC_FAILURE;
+   }
+
+   srv->cli.pipe_idx = PI_SAMR;
+
+   hnd->status = cli_samr_delete_dom_alias( &(srv->cli), mem_ctx, alias_hnd);
+
+   if(!NT_STATUS_IS_OK(hnd->status))
+      return CAC_FAILURE;
+
+   return CAC_SUCCESS;
+
+}
+
+int cac_SamAddAliasMember(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, struct SamAddAliasMember *op) {
+   SMBCSRV *srv = NULL;
+
+   if(!hnd) 
+      return CAC_FAILURE;
+
+   if(!hnd->_internal.ctx || !hnd->_internal.pipes[PI_SAMR]) {
+      hnd->status = NT_STATUS_INVALID_HANDLE;
+      return CAC_FAILURE;
+   }
+
+   if(!op || !op->in.alias_hnd || !op->in.sid || !mem_ctx) {
+      hnd->status = NT_STATUS_INVALID_PARAMETER;
+      return CAC_FAILURE;
+   }
+
+   srv = cac_GetServer(hnd);
+   if(!srv) {
+      hnd->status = NT_STATUS_UNSUCCESSFUL;
+      return CAC_FAILURE;
+   }
+
+   srv->cli.pipe_idx = PI_SAMR;
+
+   hnd->status = cli_samr_add_aliasmem( &(srv->cli), mem_ctx, op->in.alias_hnd, op->in.sid);
+
+   if(!NT_STATUS_IS_OK(hnd->status))
+      return CAC_FAILURE;
+
+   return CAC_SUCCESS;
+}
+



More information about the samba-cvs mailing list