s3-rpc_client: Added a winreg set security descriptor helper.
[amitay/samba.git] / source3 / rpc_client / cli_winreg.h
1 /*
2  *  Unix SMB/CIFS implementation.
3  *
4  *  WINREG client routines
5  *
6  *  Copyright (c) 2011      Andreas Schneider <asn@samba.org>
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 3 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
20  */
21
22 #ifndef CLI_WINREG_H
23 #define CLI_WINREG_H
24
25 /**
26  * @brief Query a key for the specified dword value.
27  *
28  * Get the data that is associated with the named value of a specified registry
29  * open key. This function ensures that the key is a dword and converts it
30  * corretly.
31  *
32  * @param[in]  mem_ctx  The memory context to use.
33  *
34  * @param[in]  h        The binding handle for the rpc connection.
35  *
36  * @param[in]  key_handle A handle to a key that MUST have been opened
37  *                        previously.
38  *
39  * @param[in]  value    The name of the value to query.
40  *
41  * @param[out] data     A pointer to store the data of the value.
42  *
43  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
44  *
45  * @return              NT_STATUS_OK on success or a corresponding error if
46  *                      there was a problem on the connection.
47  */
48 NTSTATUS dcerpc_winreg_query_dword(TALLOC_CTX *mem_ctx,
49                                    struct dcerpc_binding_handle *h,
50                                    struct policy_handle *key_handle,
51                                    const char *value,
52                                    uint32_t *data,
53                                    WERROR *pwerr);
54
55 /**
56  * @brief Query a key for the specified binary value.
57  *
58  * Get the data that is associated with the named value of a specified registry
59  * open key. This function ensures that the key is a binary value.
60  *
61  * @param[in]  mem_ctx  The memory context to use.
62  *
63  * @param[in]  h        The binding handle for the rpc connection.
64  *
65  * @param[in]  key_handle A handle to a key that MUST have been opened
66  *                        previously.
67  *
68  * @param[in]  value    The name of the value to query.
69  *
70  * @param[out] data     A pointer to store the data of the value.
71  *
72  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
73  *
74  * @return              NT_STATUS_OK on success or a corresponding error if
75  *                      there was a problem on the connection.
76  */
77 NTSTATUS dcerpc_winreg_query_binary(TALLOC_CTX *mem_ctx,
78                                     struct dcerpc_binding_handle *h,
79                                     struct policy_handle *key_handle,
80                                     const char *value,
81                                     DATA_BLOB *data,
82                                     WERROR *pwerr);
83
84 /**
85  * @brief Query a key for the specified multi sz value.
86  *
87  * Get the data that is associated with the named value of a specified registry
88  * open key. This function ensures that the key is a multi sz value.
89  *
90  * @param[in]  mem_ctx  The memory context to use.
91  *
92  * @param[in]  h        The binding handle for the rpc connection.
93  *
94  * @param[in]  key_handle A handle to a key that MUST have been opened
95  *                        previously.
96  *
97  * @param[in]  value    The name of the value to query.
98  *
99  * @param[out] data     A pointer to store the data of the value.
100  *
101  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
102  *
103  * @return              NT_STATUS_OK on success or a corresponding error if
104  *                      there was a problem on the connection.
105  */
106 NTSTATUS dcerpc_winreg_query_multi_sz(TALLOC_CTX *mem_ctx,
107                                       struct dcerpc_binding_handle *h,
108                                       struct policy_handle *key_handle,
109                                       const char *value,
110                                       const char ***data,
111                                       WERROR *pwerr);
112
113 /**
114  * @brief Query a key for the specified sz value.
115  *
116  * Get the data that is associated with the named value of a specified registry
117  * open key. This function ensures that the key is a multi sz value.
118  *
119  * @param[in]  mem_ctx  The memory context to use.
120  *
121  * @param[in]  h        The binding handle for the rpc connection.
122  *
123  * @param[in]  key_handle A handle to a key that MUST have been opened
124  *                        previously.
125  *
126  * @param[in]  value    The name of the value to query.
127  *
128  * @param[out] data     A pointer to store the data of the value.
129  *
130  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
131  *
132  * @return              NT_STATUS_OK on success or a corresponding error if
133  *                      there was a problem on the connection.
134  */
135 NTSTATUS dcerpc_winreg_query_sz(TALLOC_CTX *mem_ctx,
136                                 struct dcerpc_binding_handle *h,
137                                 struct policy_handle *key_handle,
138                                 const char *value,
139                                 const char **data,
140                                 WERROR *pwerr);
141
142 /**
143  * @brief Set a value with the specified dword data.
144  *
145  * @param[in]  mem_ctx  The memory context to use.
146  *
147  * @param[in]  h        The binding handle for the rpc connection.
148  *
149  * @param[in]  key_handle A handle to a key that MUST have been opened
150  *                        previously.
151  *
152  * @param[in]  value    The name of the value to set.
153  *
154  * @param[in]  data     The data to store in the value.
155  *
156  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
157  *
158  * @return              NT_STATUS_OK on success or a corresponding error if
159  *                      there was a problem on the connection.
160  */
161 NTSTATUS dcerpc_winreg_set_dword(TALLOC_CTX *mem_ctx,
162                                  struct dcerpc_binding_handle *h,
163                                  struct policy_handle *key_handle,
164                                  const char *value,
165                                  uint32_t data,
166                                  WERROR *pwerr);
167
168 /**
169  * @brief Set a value with the specified sz data.
170  *
171  * @param[in]  mem_ctx  The memory context to use.
172  *
173  * @param[in]  h        The binding handle for the rpc connection.
174  *
175  * @param[in]  key_handle A handle to a key that MUST have been opened
176  *                        previously.
177  *
178  * @param[in]  value    The name of the value to set.
179  *
180  * @param[in]  data     The data to store in the value.
181  *
182  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
183  *
184  * @return              NT_STATUS_OK on success or a corresponding error if
185  *                      there was a problem on the connection.
186  */
187 NTSTATUS dcerpc_winreg_set_sz(TALLOC_CTX *mem_ctx,
188                               struct dcerpc_binding_handle *h,
189                               struct policy_handle *key_handle,
190                               const char *value,
191                               const char *data,
192                               WERROR *pwerr);
193
194 /**
195  * @brief Set a value with the specified expand sz data.
196  *
197  * @param[in]  mem_ctx  The memory context to use.
198  *
199  * @param[in]  h        The binding handle for the rpc connection.
200  *
201  * @param[in]  key_handle A handle to a key that MUST have been opened
202  *                        previously.
203  *
204  * @param[in]  value    The name of the value to set.
205  *
206  * @param[in]  data     The data to store in the value.
207  *
208  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
209  *
210  * @return              NT_STATUS_OK on success or a corresponding error if
211  *                      there was a problem on the connection.
212  */
213 NTSTATUS dcerpc_winreg_set_expand_sz(TALLOC_CTX *mem_ctx,
214                                      struct dcerpc_binding_handle *h,
215                                      struct policy_handle *key_handle,
216                                      const char *value,
217                                      const char *data,
218                                      WERROR *pwerr);
219
220 /**
221  * @brief Set a value with the specified multi sz data.
222  *
223  * @param[in]  mem_ctx  The memory context to use.
224  *
225  * @param[in]  h        The binding handle for the rpc connection.
226  *
227  * @param[in]  key_handle A handle to a key that MUST have been opened
228  *                        previously.
229  *
230  * @param[in]  value    The name of the value to set.
231  *
232  * @param[in]  data     The data to store in the value.
233  *
234  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
235  *
236  * @return              NT_STATUS_OK on success or a corresponding error if
237  *                      there was a problem on the connection.
238  */
239 NTSTATUS dcerpc_winreg_set_multi_sz(TALLOC_CTX *mem_ctx,
240                                     struct dcerpc_binding_handle *h,
241                                     struct policy_handle *key_handle,
242                                     const char *value,
243                                     const char **data,
244                                     WERROR *pwerr);
245
246 /**
247  * @brief Set a value with the specified binary data.
248  *
249  * @param[in]  mem_ctx  The memory context to use.
250  *
251  * @param[in]  h        The binding handle for the rpc connection.
252  *
253  * @param[in]  key_handle A handle to a key that MUST have been opened
254  *                        previously.
255  *
256  * @param[in]  value    The name of the value to set.
257  *
258  * @param[in]  data     The data to store in the value.
259  *
260  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
261  *
262  * @return              NT_STATUS_OK on success or a corresponding error if
263  *                      there was a problem on the connection.
264  */
265 NTSTATUS dcerpc_winreg_set_binary(TALLOC_CTX *mem_ctx,
266                                   struct dcerpc_binding_handle *h,
267                                   struct policy_handle *key_handle,
268                                   const char *value,
269                                   DATA_BLOB *data,
270                                   WERROR *pwerr);
271
272 /**
273  * @brief Set a value with the specified security descriptor.
274  *
275  * @param[in]  mem_ctx  The memory context to use.
276  *
277  * @param[in]  h        The binding handle for the rpc connection.
278  *
279  * @param[in]  key_handle A handle to a key that MUST have been opened
280  *                        previously.
281  *
282  * @param[in]  value    The name of the value to set.
283  *
284  * @param[in]  data     The security descriptor to store in the value.
285  *
286  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
287  *
288  * @return              NT_STATUS_OK on success or a corresponding error if
289  *                      there was a problem on the connection.
290  */
291 NTSTATUS dcerpc_winreg_set_sd(TALLOC_CTX *mem_ctx,
292                               struct dcerpc_binding_handle *h,
293                               struct policy_handle *key_handle,
294                               const char *value,
295                               const struct security_descriptor *data,
296                               WERROR *pwerr);
297
298 /**
299  * @brief Add a value to the multi sz data.
300  *
301  * This reads the multi sz data from the given value and adds the data to the
302  * multi sz. Then it saves it to the regsitry.
303  *
304  * @param[in]  mem_ctx  The memory context to use.
305  *
306  * @param[in]  h        The binding handle for the rpc connection.
307  *
308  * @param[in]  key_handle A handle to a key that MUST have been opened
309  *                        previously.
310  *
311  * @param[in]  value    The name of the value to set.
312  *
313  * @param[in]  data     The data to add.
314  *
315  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
316  *
317  * @return              NT_STATUS_OK on success or a corresponding error if
318  *                      there was a problem on the connection.
319  */
320 NTSTATUS dcerpc_winreg_add_multi_sz(TALLOC_CTX *mem_ctx,
321                                     struct dcerpc_binding_handle *h,
322                                     struct policy_handle *key_handle,
323                                     const char *value,
324                                     const char *data,
325                                     WERROR *pwerr);
326
327 /**
328  * @brief Enumerate on the given keyhandle to get the subkey names.
329  *
330  * @param[in]  mem_ctx  The memory context to use.
331  *
332  * @param[in]  h        The binding handle for the rpc connection.
333  *
334  * @param[in]  key_handle A handle to a key that MUST have been opened
335  *                        previously.
336  *
337  * @param[out] pnum_subkeys A pointer to store the number of subkeys.
338  *
339  * @param[out] psubkeys A pointer to store the names of the subkeys.
340  *
341  * @param[out] pwerr    A pointer to a WERROR to store result of the query.
342  *
343  * @return              NT_STATUS_OK on success or a corresponding error if
344  *                      there was a problem on the connection.
345  */
346 NTSTATUS dcerpc_winreg_enum_keys(TALLOC_CTX *mem_ctx,
347                                  struct dcerpc_binding_handle *h,
348                                  struct policy_handle *key_hnd,
349                                  uint32_t *pnum_subkeys,
350                                  const char ***psubkeys,
351                                  WERROR *pwerr);
352
353 #endif /* CLI_WINREG_H */
354
355 /* vim: set ts=8 sw=8 noet cindent syntax=c.doxygen: */