Standardize License information
[openafs.git] / src / WINNT / afsadmsvr / TaAfsAdmSvrClientGroup.cpp
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 extern "C" {
11 #include <afs/param.h>
12 #include <afs/stds.h>
13 }
14
15 #include "TaAfsAdmSvrClientInternal.h"
16
17
18 /*
19  * ROUTINES ___________________________________________________________________
20  *
21  */
22
23 BOOL ADMINAPI asc_GroupChange (DWORD idClient, ASID idCell, ASID idGroup, LPAFSADMSVR_CHANGEGROUP_PARAMS pChange, ULONG *pStatus)
24 {
25    BOOL rc = TRUE;
26    ULONG status = 0;
27
28    RpcTryExcept
29       {
30       if ((rc = AfsAdmSvr_ChangeGroup (idClient, idCell, idGroup, pChange, &status)) != FALSE)
31          {
32          // If we succeeded in changing this group's properties, get the
33          // newest values for our cache.
34          //
35          ASOBJPROP Properties;
36          rc = asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, idGroup, &Properties, &status);
37          }
38       }
39    RpcExcept(1)
40       {
41       rc = FALSE;
42       status = RPC_S_CALL_FAILED_DNE;
43       }
44    RpcEndExcept
45
46    if (!rc && pStatus)
47       *pStatus = status;
48    return rc;
49 }
50
51
52 BOOL ADMINAPI asc_GroupMembersGet (DWORD idClient, ASID idCell, ASID idGroup, LPASIDLIST *ppAsidList, ULONG *pStatus)
53 {
54    BOOL rc = TRUE;
55    ULONG status = 0;
56
57    RpcTryExcept
58       {
59       rc = AfsAdmSvr_GetGroupMembers (idClient, idCell, idGroup, ppAsidList, &status);
60       }
61    RpcExcept(1)
62       {
63       rc = FALSE;
64       status = RPC_S_CALL_FAILED_DNE;
65       }
66    RpcEndExcept
67
68    if (!rc && pStatus)
69       *pStatus = status;
70    return rc;
71 }
72
73
74 BOOL ADMINAPI asc_GroupMemberAdd (DWORD idClient, ASID idCell, ASID idGroup, ASID idMember, ULONG *pStatus)
75 {
76    BOOL rc = TRUE;
77    ULONG status = 0;
78
79    RpcTryExcept
80       {
81       rc = AfsAdmSvr_AddGroupMember (idClient, idCell, idGroup, idMember, &status);
82       }
83    RpcExcept(1)
84       {
85       rc = FALSE;
86       status = RPC_S_CALL_FAILED_DNE;
87       }
88    RpcEndExcept
89
90    if (!rc && pStatus)
91       *pStatus = status;
92    return rc;
93 }
94
95
96 BOOL ADMINAPI asc_GroupMemberRemove (DWORD idClient, ASID idCell, ASID idGroup, ASID idMember, ULONG *pStatus)
97 {
98    BOOL rc = TRUE;
99    ULONG status = 0;
100
101    RpcTryExcept
102       {
103       rc = AfsAdmSvr_RemoveGroupMember (idClient, idCell, idGroup, idMember, &status);
104       }
105    RpcExcept(1)
106       {
107       rc = FALSE;
108       status = RPC_S_CALL_FAILED_DNE;
109       }
110    RpcEndExcept
111
112    if (!rc && pStatus)
113       *pStatus = status;
114    return rc;
115 }
116
117
118 BOOL ADMINAPI asc_GroupRename (DWORD idClient, ASID idCell, ASID idGroup, LPCTSTR pszNewName, ULONG *pStatus)
119 {
120    BOOL rc = TRUE;
121    ULONG status = 0;
122
123    RpcTryExcept
124       {
125       STRING szNewName = TEXT("");
126       if (pszNewName)
127          lstrcpy (szNewName, pszNewName);
128       if ((rc = AfsAdmSvr_RenameGroup (idClient, idCell, idGroup, szNewName, &status)) == TRUE)
129          {
130          // If we succeeded in changing this group's name, get the
131          // newest group properties for our cache.
132          //
133          ASOBJPROP Properties;
134          rc = asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, idGroup, &Properties, &status);
135          }
136       }
137    RpcExcept(1)
138       {
139       rc = FALSE;
140       status = RPC_S_CALL_FAILED_DNE;
141       }
142    RpcEndExcept
143
144    if (!rc && pStatus)
145       *pStatus = status;
146    return rc;
147 }
148
149
150 BOOL ADMINAPI asc_GroupMembershipGet (DWORD idClient, ASID idCell, ASID idMember, LPASIDLIST *ppAsidList, ULONG *pStatus)
151 {
152    BOOL rc = TRUE;
153    ULONG status = 0;
154
155    RpcTryExcept
156       {
157       rc = AfsAdmSvr_GetGroupMembership (idClient, idCell, idMember, ppAsidList, &status);
158       }
159    RpcExcept(1)
160       {
161       rc = FALSE;
162       status = RPC_S_CALL_FAILED_DNE;
163       }
164    RpcEndExcept
165
166    if (!rc && pStatus)
167       *pStatus = status;
168    return rc;
169 }
170
171
172 BOOL ADMINAPI asc_GroupOwnershipGet (DWORD idClient, ASID idCell, ASID idOwner, LPASIDLIST *ppAsidList, ULONG *pStatus)
173 {
174    BOOL rc = TRUE;
175    ULONG status = 0;
176
177    RpcTryExcept
178       {
179       rc = AfsAdmSvr_GetGroupOwnership (idClient, idCell, idOwner, ppAsidList, &status);
180       }
181    RpcExcept(1)
182       {
183       rc = FALSE;
184       status = RPC_S_CALL_FAILED_DNE;
185       }
186    RpcEndExcept
187
188    if (!rc && pStatus)
189       *pStatus = status;
190    return rc;
191 }
192
193
194 BOOL ADMINAPI asc_GroupCreate (DWORD idClient, ASID idCell, LPAFSADMSVR_CREATEGROUP_PARAMS pCreate, ASID *pidGroup, ULONG *pStatus)
195 {
196    BOOL rc = TRUE;
197    ULONG status = 0;
198
199    RpcTryExcept
200       {
201       if ((rc = AfsAdmSvr_CreateGroup (idClient, idCell, pCreate, pidGroup, &status)) == TRUE)
202          {
203          // If we succeeded in creating this group, get the
204          // initial group properties for our cache.
205          //
206          ASOBJPROP Properties;
207          rc = asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, *pidGroup, &Properties, &status);
208          }
209       }
210    RpcExcept(1)
211       {
212       rc = FALSE;
213       status = RPC_S_CALL_FAILED_DNE;
214       }
215    RpcEndExcept
216
217    if (!rc && pStatus)
218       *pStatus = status;
219    return rc;
220 }
221
222
223 BOOL ADMINAPI asc_GroupDelete (DWORD idClient, ASID idCell, ASID idGroup, ULONG *pStatus)
224 {
225    BOOL rc = TRUE;
226    ULONG status = 0;
227
228    RpcTryExcept
229       {
230       if ((rc = AfsAdmSvr_DeleteGroup (idClient, idCell, idGroup, &status)) == TRUE)
231          {
232          // If we succeeded in deleting this group, clean up our cache.
233          // Expect this call to fail (the group's deleted, right?)
234          //
235          ASOBJPROP Properties;
236          ULONG dummy;
237          (void)asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, idGroup, &Properties, &dummy);
238          }
239       }
240    RpcExcept(1)
241       {
242       rc = FALSE;
243       status = RPC_S_CALL_FAILED_DNE;
244       }
245    RpcEndExcept
246
247    if (!rc && pStatus)
248       *pStatus = status;
249    return rc;
250 }
251