Standardize License information
[openafs.git] / src / WINNT / afsadmsvr / TaAfsAdmSvrClientUser.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_UserChange (DWORD idClient, ASID idCell, ASID idUser, LPAFSADMSVR_CHANGEUSER_PARAMS pChange, ULONG *pStatus)
24 {
25    BOOL rc = TRUE;
26    ULONG status = 0;
27
28    RpcTryExcept
29       {
30       if ((rc = AfsAdmSvr_ChangeUser (idClient, idCell, idUser, pChange, &status)) != FALSE)
31          {
32          // If we succeeded in changing this user's properties, get the
33          // newest values for our cache.
34          //
35          ASOBJPROP Properties;
36          rc = asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, idUser, &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_UserPasswordSet (DWORD idClient, ASID idCell, ASID idUser, int keyVersion, LPCTSTR pkeyString, PBYTE pkeyData, ULONG *pStatus)
53 {
54    BOOL rc = TRUE;
55    ULONG status = 0;
56
57    RpcTryExcept
58       {
59       BYTE keyData[ ENCRYPTIONKEYLENGTH ];
60       if (pkeyData)
61          memcpy (keyData, pkeyData, sizeof(keyData));
62       else
63          memset (keyData, 0x00, sizeof(keyData));
64
65       STRING keyString;
66       if (pkeyString)
67          lstrcpy (keyString, pkeyString);
68       else
69          memset (keyString, 0x00, sizeof(keyString));
70
71       if ((rc = AfsAdmSvr_SetUserPassword (idClient, idCell, idUser, keyVersion, keyString, keyData, &status)) == TRUE)
72          {
73          // If we succeeded in changing this user's password, get the
74          // newest user properties for our cache.
75          //
76          ASOBJPROP Properties;
77          rc = asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, idUser, &Properties, &status);
78          }
79       }
80    RpcExcept(1)
81       {
82       rc = FALSE;
83       status = RPC_S_CALL_FAILED_DNE;
84       }
85    RpcEndExcept
86
87    if (!rc && pStatus)
88       *pStatus = status;
89    return rc;
90 }
91
92
93 BOOL ADMINAPI asc_UserUnlock (DWORD idClient, ASID idCell, ASID idUser, ULONG *pStatus)
94 {
95    BOOL rc = TRUE;
96    ULONG status = 0;
97
98    RpcTryExcept
99       {
100       if ((rc = AfsAdmSvr_UnlockUser (idClient, idCell, idUser, &status)) == TRUE)
101          {
102          // If we succeeded in unlocking this user's account, get the
103          // newest user properties for our cache.
104          //
105          ASOBJPROP Properties;
106          rc = asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, idUser, &Properties, &status);
107          }
108       }
109    RpcExcept(1)
110       {
111       rc = FALSE;
112       status = RPC_S_CALL_FAILED_DNE;
113       }
114    RpcEndExcept
115
116    if (!rc && pStatus)
117       *pStatus = status;
118    return rc;
119 }
120
121
122 BOOL ADMINAPI asc_UserCreate (DWORD idClient, ASID idCell, LPAFSADMSVR_CREATEUSER_PARAMS pCreate, ASID *pidUser, ULONG *pStatus)
123 {
124    BOOL rc = TRUE;
125    ULONG status = 0;
126
127    RpcTryExcept
128       {
129       if ((rc = AfsAdmSvr_CreateUser (idClient, idCell, pCreate, pidUser, &status)) == TRUE)
130          {
131          // If we succeeded in creating this user's account, get the
132          // initial user properties for our cache.
133          //
134          ASOBJPROP Properties;
135          rc = asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, *pidUser, &Properties, &status);
136          }
137       }
138    RpcExcept(1)
139       {
140       rc = FALSE;
141       status = RPC_S_CALL_FAILED_DNE;
142       }
143    RpcEndExcept
144
145    if (!rc && pStatus)
146       *pStatus = status;
147    return rc;
148 }
149
150
151 BOOL ADMINAPI asc_UserDelete (DWORD idClient, ASID idCell, ASID idUser, LPAFSADMSVR_DELETEUSER_PARAMS pDelete, ULONG *pStatus)
152 {
153    BOOL rc = TRUE;
154    ULONG status = 0;
155
156    RpcTryExcept
157       {
158       if ((rc = AfsAdmSvr_DeleteUser (idClient, idCell, idUser, pDelete, &status)) == TRUE)
159          {
160          // If we succeeded in deleting this user's account, clean up our cache.
161          // Expect this call to fail (the user's deleted, right?)
162          //
163          ASOBJPROP Properties;
164          ULONG dummy;
165          (void)asc_ObjectPropertiesGet (idClient, GET_ALL_DATA, idCell, idUser, &Properties, &dummy);
166          }
167       }
168    RpcExcept(1)
169       {
170       rc = FALSE;
171       status = RPC_S_CALL_FAILED_DNE;
172       }
173    RpcEndExcept
174
175    if (!rc && pStatus)
176       *pStatus = status;
177    return rc;
178 }
179