2 Unix SMB/CIFS implementation.
4 Copyright (C) Simo Sorce 2002
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 /*******************************************************************
25 Create a SEC_ACL structure.
26 ********************************************************************/
28 static SEC_ACL
*make_sec_acl(TALLOC_CTX
*ctx
, uint16 revision
, int num_aces
, SEC_ACE
*ace_list
)
33 if((dst
= (SEC_ACL
*)talloc_zero(ctx
,sizeof(SEC_ACL
))) == NULL
)
36 dst
->revision
= revision
;
37 dst
->num_aces
= num_aces
;
38 dst
->size
= SEC_ACL_HEADER_SIZE
;
40 /* Now we need to return a non-NULL address for the ace list even
41 if the number of aces required is zero. This is because there
42 is a distinct difference between a NULL ace and an ace with zero
43 entries in it. This is achieved by checking that num_aces is a
47 ((dst
->ace
= (SEC_ACE
*)talloc(ctx
, sizeof(SEC_ACE
) * num_aces
))
52 for (i
= 0; i
< num_aces
; i
++) {
53 dst
->ace
[i
] = ace_list
[i
]; /* Structure copy. */
54 dst
->size
+= ace_list
[i
].size
;
62 /*******************************************************************
63 Duplicate a SEC_ACL structure.
64 ********************************************************************/
66 static SEC_ACL
*dup_sec_acl(TALLOC_CTX
*ctx
, SEC_ACL
*src
)
71 return make_sec_acl(ctx
, src
->revision
, src
->num_aces
, src
->ace
);
76 /*******************************************************************
77 Creates a SEC_DESC structure
78 ********************************************************************/
80 static SEC_DESC
*make_sec_desc(TALLOC_CTX
*ctx
, uint16 revision
,
81 DOM_SID
*owner_sid
, DOM_SID
*grp_sid
,
82 SEC_ACL
*sacl
, SEC_ACL
*dacl
, size_t *sd_size
)
86 uint32 offset_sid
= SEC_DESC_HEADER_SIZE
;
87 uint32 offset_acl
= 0;
91 if(( dst
= (SEC_DESC
*)talloc_zero(ctx
, sizeof(SEC_DESC
))) == NULL
)
94 dst
->revision
= revision
;
95 dst
->type
= SEC_DESC_SELF_RELATIVE
;
97 if (sacl
) dst
->type
|= SEC_DESC_SACL_PRESENT
;
98 if (dacl
) dst
->type
|= SEC_DESC_DACL_PRESENT
;
100 dst
->off_owner_sid
= 0;
101 dst
->off_grp_sid
= 0;
105 if(owner_sid
&& ((dst
->owner_sid
= sid_dup_talloc(ctx
,owner_sid
)) == NULL
))
108 if(grp_sid
&& ((dst
->grp_sid
= sid_dup_talloc(ctx
,grp_sid
)) == NULL
))
111 if(sacl
&& ((dst
->sacl
= dup_sec_acl(ctx
, sacl
)) == NULL
))
114 if(dacl
&& ((dst
->dacl
= dup_sec_acl(ctx
, dacl
)) == NULL
))
120 * Work out the linearization sizes.
122 if (dst
->owner_sid
!= NULL
) {
125 offset
= SEC_DESC_HEADER_SIZE
;
127 offset
+= sid_size(dst
->owner_sid
);
130 if (dst
->grp_sid
!= NULL
) {
133 offset
= SEC_DESC_HEADER_SIZE
;
135 offset
+= sid_size(dst
->grp_sid
);
138 if (dst
->sacl
!= NULL
) {
140 offset_acl
= SEC_DESC_HEADER_SIZE
;
142 dst
->off_sacl
= offset_acl
;
143 offset_acl
+= dst
->sacl
->size
;
144 offset
+= dst
->sacl
->size
;
145 offset_sid
+= dst
->sacl
->size
;
148 if (dst
->dacl
!= NULL
) {
151 offset_acl
= SEC_DESC_HEADER_SIZE
;
153 dst
->off_dacl
= offset_acl
;
154 offset_acl
+= dst
->dacl
->size
;
155 offset
+= dst
->dacl
->size
;
156 offset_sid
+= dst
->dacl
->size
;
159 *sd_size
= (size_t)((offset
== 0) ? SEC_DESC_HEADER_SIZE
: offset
);
161 if (dst
->owner_sid
!= NULL
)
162 dst
->off_owner_sid
= offset_sid
;
164 /* sid_size() returns 0 if the sid is NULL so this is ok */
166 if (dst
->grp_sid
!= NULL
)
167 dst
->off_grp_sid
= offset_sid
+ sid_size(dst
->owner_sid
);
177 /*******************************************************************
178 Duplicate a SEC_DESC structure.
179 ********************************************************************/
181 static SEC_DESC
*dup_sec_desc( TALLOC_CTX
*ctx
, SEC_DESC
*src
)
188 return make_sec_desc( ctx
, src
->revision
,
189 src
->owner_sid
, src
->grp_sid
, src
->sacl
,
199 extern GUMS_FUNCTIONS
*gums_storage
;
201 /* Functions to get/set info from a GUMS object */
203 NTSTATUS
gums_get_object_type(uint32
*type
, const GUMS_OBJECT
*obj
)
206 return NT_STATUS_INVALID_PARAMETER
;
212 NTSTATUS
gums_create_object(GUMS_OBJECT
**obj
, uint32 type
)
214 TALLOC_CTX
*mem_ctx
= talloc_init("gums_create_object");
218 go
= talloc_zero(mem_ctx
, sizeof(GUMS_OBJECT
));
219 go
->mem_ctx
= mem_ctx
;
221 go
->version
= GUMS_OBJECT_VERSION
;
224 case GUMS_OBJ_DOMAIN
:
228 case GUMS_OBJ_WORKSTATION_TRUST:
229 case GUMS_OBJ_SERVER_TRUST:
230 case GUMS_OBJ_DOMAIN_TRUST:
232 case GUMS_OBJ_NORMAL_USER
:
233 go
->data
.user
= (GUMS_USER
*)talloc_zero(mem_ctx
, sizeof(GUMS_USER
));
238 go
->data
.group
= (GUMS_GROUP
*)talloc_zero(mem_ctx
, sizeof(GUMS_GROUP
));
242 /* TODO: throw error */
243 ret
= NT_STATUS_OBJECT_TYPE_MISMATCH
;
247 if (!(go
->data
.user
)) {
248 ret
= NT_STATUS_NO_MEMORY
;
249 DEBUG(0, ("gums_create_object: Out of memory!\n"));
257 talloc_destroy(go
->mem_ctx
);
262 NTSTATUS
gums_get_object_seq_num(uint32
*version
, const GUMS_OBJECT
*obj
)
264 if (!version
|| !obj
)
265 return NT_STATUS_INVALID_PARAMETER
;
267 *version
= obj
->version
;
271 NTSTATUS
gums_set_object_seq_num(GUMS_OBJECT
*obj
, uint32 version
)
274 return NT_STATUS_INVALID_PARAMETER
;
276 obj
->version
= version
;
280 NTSTATUS
gums_get_sec_desc(SEC_DESC
**sec_desc
, const GUMS_OBJECT
*obj
)
282 if (!sec_desc
|| !obj
)
283 return NT_STATUS_INVALID_PARAMETER
;
285 *sec_desc
= obj
->sec_desc
;
289 NTSTATUS
gums_set_sec_desc(GUMS_OBJECT
*obj
, const SEC_DESC
*sec_desc
)
291 if (!obj
|| !sec_desc
)
292 return NT_STATUS_INVALID_PARAMETER
;
294 obj
->sec_desc
= dup_sec_desc(obj
->mem_ctx
, sec_desc
);
295 if (!(obj
->sec_desc
)) return NT_STATUS_UNSUCCESSFUL
;
299 NTSTATUS
gums_get_object_sid(DOM_SID
**sid
, const GUMS_OBJECT
*obj
)
302 return NT_STATUS_INVALID_PARAMETER
;
308 NTSTATUS
gums_set_object_sid(GUMS_OBJECT
*obj
, const DOM_SID
*sid
)
311 return NT_STATUS_INVALID_PARAMETER
;
313 obj
->sid
= sid_dup_talloc(obj
->mem_ctx
, sid
);
314 if (!(obj
->sid
)) return NT_STATUS_UNSUCCESSFUL
;
318 NTSTATUS
gums_get_object_name(char **name
, const GUMS_OBJECT
*obj
)
321 return NT_STATUS_INVALID_PARAMETER
;
327 NTSTATUS
gums_set_object_name(GUMS_OBJECT
*obj
, const char *name
)
330 return NT_STATUS_INVALID_PARAMETER
;
332 obj
->name
= (char *)talloc_strdup(obj
->mem_ctx
, name
);
333 if (!(obj
->name
)) return NT_STATUS_UNSUCCESSFUL
;
337 NTSTATUS
gums_get_object_description(char **description
, const GUMS_OBJECT
*obj
)
339 if (!description
|| !obj
)
340 return NT_STATUS_INVALID_PARAMETER
;
342 *description
= obj
->description
;
346 NTSTATUS
gums_set_object_description(GUMS_OBJECT
*obj
, const char *description
)
348 if (!obj
|| !description
)
349 return NT_STATUS_INVALID_PARAMETER
;
351 obj
->description
= (char *)talloc_strdup(obj
->mem_ctx
, description
);
352 if (!(obj
->description
)) return NT_STATUS_UNSUCCESSFUL
;
356 /* User specific functions */
359 NTSTATUS gums_get_object_privileges(PRIVILEGE_SET **priv_set, const GUMS_OBJECT *obj)
362 return NT_STATUS_INVALID_PARAMETER;
364 *priv_set = obj->priv_set;
369 NTSTATUS
gums_get_domain_next_rid(uint32
*rid
, const GUMS_OBJECT
*obj
)
372 return NT_STATUS_INVALID_PARAMETER
;
374 if (obj
->type
!= GUMS_OBJ_DOMAIN
)
375 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
377 *rid
= obj
->data
.domain
->next_rid
;
381 NTSTATUS
gums_set_domain_next_rid(GUMS_OBJECT
*obj
, uint32 rid
)
384 return NT_STATUS_INVALID_PARAMETER
;
386 if (obj
->type
!= GUMS_OBJ_DOMAIN
)
387 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
389 obj
->data
.domain
->next_rid
= rid
;
393 NTSTATUS
gums_get_user_pri_group(DOM_SID
**sid
, const GUMS_OBJECT
*obj
)
396 return NT_STATUS_INVALID_PARAMETER
;
398 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
399 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
401 *sid
= obj
->data
.user
->group_sid
;
405 NTSTATUS
gums_set_user_pri_group(GUMS_OBJECT
*obj
, const DOM_SID
*sid
)
408 return NT_STATUS_INVALID_PARAMETER
;
410 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
411 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
413 obj
->data
.user
->group_sid
= sid_dup_talloc(obj
->mem_ctx
, sid
);
414 if (!(obj
->data
.user
->group_sid
)) return NT_STATUS_NO_MEMORY
;
418 NTSTATUS
gums_get_user_nt_pwd(DATA_BLOB
**nt_pwd
, const GUMS_OBJECT
*obj
)
421 return NT_STATUS_INVALID_PARAMETER
;
423 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
424 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
426 *nt_pwd
= &(obj
->data
.user
->nt_pw
);
430 NTSTATUS
gums_set_user_nt_pwd(GUMS_OBJECT
*obj
, const DATA_BLOB nt_pwd
)
432 if (!obj
|| nt_pwd
.length
!= NT_HASH_LEN
)
433 return NT_STATUS_INVALID_PARAMETER
;
435 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
436 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
438 obj
->data
.user
->nt_pw
= data_blob_talloc(obj
->mem_ctx
, nt_pwd
.data
, nt_pwd
.length
);
442 NTSTATUS
gums_get_user_lm_pwd(DATA_BLOB
**lm_pwd
, const GUMS_OBJECT
*obj
)
445 return NT_STATUS_INVALID_PARAMETER
;
447 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
448 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
450 *lm_pwd
= &(obj
->data
.user
->lm_pw
);
454 NTSTATUS
gums_set_user_lm_pwd(GUMS_OBJECT
*obj
, const DATA_BLOB lm_pwd
)
456 if (!obj
|| lm_pwd
.length
!= LM_HASH_LEN
)
457 return NT_STATUS_INVALID_PARAMETER
;
459 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
460 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
462 obj
->data
.user
->lm_pw
= data_blob_talloc(obj
->mem_ctx
, lm_pwd
.data
, lm_pwd
.length
);
466 NTSTATUS
gums_get_user_fullname(char **fullname
, const GUMS_OBJECT
*obj
)
468 if (!fullname
|| !obj
)
469 return NT_STATUS_INVALID_PARAMETER
;
471 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
472 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
474 *fullname
= obj
->data
.user
->full_name
;
478 NTSTATUS
gums_set_user_fullname(GUMS_OBJECT
*obj
, const char *fullname
)
480 if (!obj
|| !fullname
)
481 return NT_STATUS_INVALID_PARAMETER
;
483 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
484 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
486 obj
->data
.user
->full_name
= (char *)talloc_strdup(obj
->mem_ctx
, fullname
);
487 if (!(obj
->data
.user
->full_name
)) return NT_STATUS_NO_MEMORY
;
491 NTSTATUS
gums_get_user_homedir(char **homedir
, const GUMS_OBJECT
*obj
)
493 if (!homedir
|| !obj
)
494 return NT_STATUS_INVALID_PARAMETER
;
496 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
497 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
499 *homedir
= obj
->data
.user
->home_dir
;
503 NTSTATUS
gums_set_user_homedir(GUMS_OBJECT
*obj
, const char *homedir
)
505 if (!obj
|| !homedir
)
506 return NT_STATUS_INVALID_PARAMETER
;
508 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
509 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
511 obj
->data
.user
->home_dir
= (char *)talloc_strdup(obj
->mem_ctx
, homedir
);
512 if (!(obj
->data
.user
->home_dir
)) return NT_STATUS_NO_MEMORY
;
516 NTSTATUS
gums_get_user_dir_drive(char **dirdrive
, const GUMS_OBJECT
*obj
)
518 if (!dirdrive
|| !obj
)
519 return NT_STATUS_INVALID_PARAMETER
;
521 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
522 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
524 *dirdrive
= obj
->data
.user
->dir_drive
;
528 NTSTATUS
gums_set_user_dir_drive(GUMS_OBJECT
*obj
, const char *dir_drive
)
530 if (!obj
|| !dir_drive
)
531 return NT_STATUS_INVALID_PARAMETER
;
533 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
534 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
536 obj
->data
.user
->dir_drive
= (char *)talloc_strdup(obj
->mem_ctx
, dir_drive
);
537 if (!(obj
->data
.user
->dir_drive
)) return NT_STATUS_NO_MEMORY
;
541 NTSTATUS
gums_get_user_logon_script(char **logon_script
, const GUMS_OBJECT
*obj
)
543 if (!logon_script
|| !obj
)
544 return NT_STATUS_INVALID_PARAMETER
;
546 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
547 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
549 *logon_script
= obj
->data
.user
->logon_script
;
553 NTSTATUS
gums_set_user_logon_script(GUMS_OBJECT
*obj
, const char *logon_script
)
555 if (!obj
|| !logon_script
)
556 return NT_STATUS_INVALID_PARAMETER
;
558 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
559 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
561 obj
->data
.user
->logon_script
= (char *)talloc_strdup(obj
->mem_ctx
, logon_script
);
562 if (!(obj
->data
.user
->logon_script
)) return NT_STATUS_NO_MEMORY
;
566 NTSTATUS
gums_get_user_profile_path(char **profile_path
, const GUMS_OBJECT
*obj
)
568 if (!profile_path
|| !obj
)
569 return NT_STATUS_INVALID_PARAMETER
;
571 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
572 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
574 *profile_path
= obj
->data
.user
->profile_path
;
578 NTSTATUS
gums_set_user_profile_path(GUMS_OBJECT
*obj
, const char *profile_path
)
580 if (!obj
|| !profile_path
)
581 return NT_STATUS_INVALID_PARAMETER
;
583 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
584 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
586 obj
->data
.user
->profile_path
= (char *)talloc_strdup(obj
->mem_ctx
, profile_path
);
587 if (!(obj
->data
.user
->profile_path
)) return NT_STATUS_NO_MEMORY
;
591 NTSTATUS
gums_get_user_workstations(char **workstations
, const GUMS_OBJECT
*obj
)
593 if (!workstations
|| !obj
)
594 return NT_STATUS_INVALID_PARAMETER
;
596 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
597 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
599 *workstations
= obj
->data
.user
->workstations
;
603 NTSTATUS
gums_set_user_workstations(GUMS_OBJECT
*obj
, const char *workstations
)
605 if (!obj
|| !workstations
)
606 return NT_STATUS_INVALID_PARAMETER
;
608 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
609 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
611 obj
->data
.user
->workstations
= (char *)talloc_strdup(obj
->mem_ctx
, workstations
);
612 if (!(obj
->data
.user
->workstations
)) return NT_STATUS_NO_MEMORY
;
616 NTSTATUS
gums_get_user_unknown_str(char **unknown_str
, const GUMS_OBJECT
*obj
)
618 if (!unknown_str
|| !obj
)
619 return NT_STATUS_INVALID_PARAMETER
;
621 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
622 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
624 *unknown_str
= obj
->data
.user
->unknown_str
;
628 NTSTATUS
gums_set_user_unknown_str(GUMS_OBJECT
*obj
, const char *unknown_str
)
630 if (!obj
|| !unknown_str
)
631 return NT_STATUS_INVALID_PARAMETER
;
633 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
634 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
636 obj
->data
.user
->unknown_str
= (char *)talloc_strdup(obj
->mem_ctx
, unknown_str
);
637 if (!(obj
->data
.user
->unknown_str
)) return NT_STATUS_NO_MEMORY
;
641 NTSTATUS
gums_get_user_munged_dial(char **munged_dial
, const GUMS_OBJECT
*obj
)
643 if (!munged_dial
|| !obj
)
644 return NT_STATUS_INVALID_PARAMETER
;
646 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
647 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
649 *munged_dial
= obj
->data
.user
->munged_dial
;
653 NTSTATUS
gums_set_user_munged_dial(GUMS_OBJECT
*obj
, const char *munged_dial
)
655 if (!obj
|| !munged_dial
)
656 return NT_STATUS_INVALID_PARAMETER
;
658 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
659 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
661 obj
->data
.user
->munged_dial
= (char *)talloc_strdup(obj
->mem_ctx
, munged_dial
);
662 if (!(obj
->data
.user
->munged_dial
)) return NT_STATUS_NO_MEMORY
;
666 NTSTATUS
gums_get_user_logon_time(NTTIME
*logon_time
, const GUMS_OBJECT
*obj
)
668 if (!logon_time
|| !obj
)
669 return NT_STATUS_INVALID_PARAMETER
;
671 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
672 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
674 *logon_time
= obj
->data
.user
->logon_time
;
678 NTSTATUS
gums_set_user_logon_time(GUMS_OBJECT
*obj
, NTTIME logon_time
)
681 return NT_STATUS_INVALID_PARAMETER
;
683 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
684 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
686 obj
->data
.user
->logon_time
= logon_time
;
690 NTSTATUS
gums_get_user_logoff_time(NTTIME
*logoff_time
, const GUMS_OBJECT
*obj
)
692 if (!logoff_time
|| !obj
)
693 return NT_STATUS_INVALID_PARAMETER
;
695 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
696 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
698 *logoff_time
= obj
->data
.user
->logoff_time
;
702 NTSTATUS
gums_set_user_logoff_time(GUMS_OBJECT
*obj
, NTTIME logoff_time
)
705 return NT_STATUS_INVALID_PARAMETER
;
707 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
708 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
710 obj
->data
.user
->logoff_time
= logoff_time
;
714 NTSTATUS
gums_get_user_kickoff_time(NTTIME
*kickoff_time
, const GUMS_OBJECT
*obj
)
716 if (!kickoff_time
|| !obj
)
717 return NT_STATUS_INVALID_PARAMETER
;
719 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
720 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
722 *kickoff_time
= obj
->data
.user
->kickoff_time
;
726 NTSTATUS
gums_set_user_kickoff_time(GUMS_OBJECT
*obj
, NTTIME kickoff_time
)
729 return NT_STATUS_INVALID_PARAMETER
;
731 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
732 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
734 obj
->data
.user
->kickoff_time
= kickoff_time
;
738 NTSTATUS
gums_get_user_pass_last_set_time(NTTIME
*pass_last_set_time
, const GUMS_OBJECT
*obj
)
740 if (!pass_last_set_time
|| !obj
)
741 return NT_STATUS_INVALID_PARAMETER
;
743 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
744 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
746 *pass_last_set_time
= obj
->data
.user
->pass_last_set_time
;
750 NTSTATUS
gums_set_user_pass_last_set_time(GUMS_OBJECT
*obj
, NTTIME pass_last_set_time
)
753 return NT_STATUS_INVALID_PARAMETER
;
755 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
756 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
758 obj
->data
.user
->pass_last_set_time
= pass_last_set_time
;
762 NTSTATUS
gums_get_user_pass_can_change_time(NTTIME
*pass_can_change_time
, const GUMS_OBJECT
*obj
)
764 if (!pass_can_change_time
|| !obj
)
765 return NT_STATUS_INVALID_PARAMETER
;
767 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
768 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
770 *pass_can_change_time
= obj
->data
.user
->pass_can_change_time
;
774 NTSTATUS
gums_set_user_pass_can_change_time(GUMS_OBJECT
*obj
, NTTIME pass_can_change_time
)
777 return NT_STATUS_INVALID_PARAMETER
;
779 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
780 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
782 obj
->data
.user
->pass_can_change_time
= pass_can_change_time
;
786 NTSTATUS
gums_get_user_pass_must_change_time(NTTIME
*pass_must_change_time
, const GUMS_OBJECT
*obj
)
788 if (!pass_must_change_time
|| !obj
)
789 return NT_STATUS_INVALID_PARAMETER
;
791 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
792 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
794 *pass_must_change_time
= obj
->data
.user
->pass_must_change_time
;
798 NTSTATUS
gums_set_user_pass_must_change_time(GUMS_OBJECT
*obj
, NTTIME pass_must_change_time
)
801 return NT_STATUS_INVALID_PARAMETER
;
803 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
804 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
806 obj
->data
.user
->pass_must_change_time
= pass_must_change_time
;
810 NTSTATUS
gums_get_user_logon_divs(uint16
*logon_divs
, const GUMS_OBJECT
*obj
)
812 if (!logon_divs
|| !obj
)
813 return NT_STATUS_INVALID_PARAMETER
;
815 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
816 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
818 *logon_divs
= obj
->data
.user
->logon_divs
;
822 NTSTATUS
gums_set_user_logon_divs(GUMS_OBJECT
*obj
, uint16 logon_divs
)
824 if (!obj
|| !logon_divs
)
825 return NT_STATUS_INVALID_PARAMETER
;
827 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
828 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
830 obj
->data
.user
->logon_divs
= logon_divs
;
834 NTSTATUS
gums_get_user_hours_len(uint32
*hours_len
, const GUMS_OBJECT
*obj
)
836 if (!hours_len
|| !obj
)
837 return NT_STATUS_INVALID_PARAMETER
;
839 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
840 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
842 *hours_len
= obj
->data
.user
->hours_len
;
846 NTSTATUS
gums_set_user_hours_len(GUMS_OBJECT
*obj
, uint32 hours_len
)
849 return NT_STATUS_INVALID_PARAMETER
;
851 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
852 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
854 obj
->data
.user
->hours_len
= hours_len
;
858 NTSTATUS
gums_get_user_hours(uint8
**hours
, const GUMS_OBJECT
*obj
)
861 return NT_STATUS_INVALID_PARAMETER
;
863 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
864 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
866 *hours
= obj
->data
.user
->hours
;
870 /* WARNING: always set hours_len before hours */
871 NTSTATUS
gums_set_user_hours(GUMS_OBJECT
*obj
, const uint8
*hours
)
874 return NT_STATUS_INVALID_PARAMETER
;
876 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
877 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
879 if (obj
->data
.user
->hours_len
== 0)
880 DEBUG(10, ("gums_set_user_hours: Warning, hours_len is zero!\n"));
882 obj
->data
.user
->hours
= (uint8
*)talloc_memdup(obj
->mem_ctx
, hours
, obj
->data
.user
->hours_len
);
883 if (!(obj
->data
.user
->hours
) & (obj
->data
.user
->hours_len
!= 0)) return NT_STATUS_NO_MEMORY
;
887 NTSTATUS
gums_get_user_unknown_3(uint32
*unknown_3
, const GUMS_OBJECT
*obj
)
889 if (!unknown_3
|| !obj
)
890 return NT_STATUS_INVALID_PARAMETER
;
892 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
893 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
895 *unknown_3
= obj
->data
.user
->unknown_3
;
899 NTSTATUS
gums_set_user_unknown_3(GUMS_OBJECT
*obj
, uint32 unknown_3
)
902 return NT_STATUS_INVALID_PARAMETER
;
904 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
905 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
907 obj
->data
.user
->unknown_3
= unknown_3
;
911 NTSTATUS
gums_get_user_unknown_5(uint32
*unknown_5
, const GUMS_OBJECT
*obj
)
913 if (!unknown_5
|| !obj
)
914 return NT_STATUS_INVALID_PARAMETER
;
916 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
917 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
919 *unknown_5
= obj
->data
.user
->unknown_5
;
923 NTSTATUS
gums_set_user_unknown_5(GUMS_OBJECT
*obj
, uint32 unknown_5
)
926 return NT_STATUS_INVALID_PARAMETER
;
928 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
929 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
931 obj
->data
.user
->unknown_5
= unknown_5
;
935 NTSTATUS
gums_get_user_unknown_6(uint32
*unknown_6
, const GUMS_OBJECT
*obj
)
937 if (!unknown_6
|| !obj
)
938 return NT_STATUS_INVALID_PARAMETER
;
940 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
941 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
943 *unknown_6
= obj
->data
.user
->unknown_6
;
947 NTSTATUS
gums_set_user_unknown_6(GUMS_OBJECT
*obj
, uint32 unknown_6
)
950 return NT_STATUS_INVALID_PARAMETER
;
952 if (obj
->type
!= GUMS_OBJ_NORMAL_USER
)
953 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
955 obj
->data
.user
->unknown_6
= unknown_6
;
959 /* Group specific functions */
961 NTSTATUS
gums_get_group_members(uint32
*count
, DOM_SID
**members
, const GUMS_OBJECT
*obj
)
963 if (!count
|| !members
|| !obj
)
964 return NT_STATUS_INVALID_PARAMETER
;
966 if (obj
->type
!= GUMS_OBJ_GROUP
&&
967 obj
->type
!= GUMS_OBJ_ALIAS
)
968 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
970 *count
= obj
->data
.group
->count
;
971 *members
= *(obj
->data
.group
->members
);
975 NTSTATUS
gums_set_group_members(GUMS_OBJECT
*obj
, uint32 count
, DOM_SID
**members
)
979 if (!obj
|| !members
|| !members
)
980 return NT_STATUS_INVALID_PARAMETER
;
982 if (obj
->type
!= GUMS_OBJ_GROUP
&&
983 obj
->type
!= GUMS_OBJ_ALIAS
)
984 return NT_STATUS_OBJECT_TYPE_MISMATCH
;
986 obj
->data
.group
->count
= count
;
989 obj
->data
.group
->members
[n
] = sid_dup_talloc(obj
->mem_ctx
, members
[n
]);
990 if (!(obj
->data
.group
->members
[n
])) return NT_STATUS_NO_MEMORY
;
996 /* data_store set functions */
998 NTSTATUS
gums_create_commit_set(GUMS_COMMIT_SET
**com_set
, TALLOC_CTX
*ctx
, DOM_SID
*sid
, uint32 type
)
1000 TALLOC_CTX
*mem_ctx
;
1001 GUMS_COMMIT_SET
*set
;
1003 mem_ctx
= talloc_init("commit_set");
1004 if (mem_ctx
== NULL
)
1005 return NT_STATUS_NO_MEMORY
;
1006 set
= (GUMS_COMMIT_SET
*)talloc(mem_ctx
, sizeof(GUMS_COMMIT_SET
));
1008 talloc_destroy(mem_ctx
);
1009 return NT_STATUS_NO_MEMORY
;
1012 set
->mem_ctx
= mem_ctx
;
1014 sid_copy(&(set
->sid
), sid
);
1019 return NT_STATUS_OK
;
1022 NTSTATUS
gums_cs_set_sec_desc(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, SEC_DESC
*sec_desc
)
1024 GUMS_DATA_SET
*data_set
;
1025 SEC_DESC
*new_sec_desc
;
1027 if (!mem_ctx
|| !com_set
|| !sec_desc
)
1028 return NT_STATUS_INVALID_PARAMETER
;
1030 com_set
->count
= com_set
->count
+ 1;
1031 if (com_set
->count
== 1) { /* first data set */
1032 data_set
= (GUMS_DATA_SET
*)talloc(mem_ctx
, sizeof(GUMS_DATA_SET
));
1034 data_set
= (GUMS_DATA_SET
*)talloc_realloc(mem_ctx
, com_set
->data
, sizeof(GUMS_DATA_SET
) * com_set
->count
);
1036 if (data_set
== NULL
)
1037 return NT_STATUS_NO_MEMORY
;
1039 com_set
->data
[0] = data_set
;
1040 data_set
= ((com_set
->data
)[com_set
->count
- 1]);
1042 data_set
->type
= GUMS_SET_SEC_DESC
;
1043 new_sec_desc
= dup_sec_desc(mem_ctx
, sec_desc
);
1044 if (new_sec_desc
== NULL
)
1045 return NT_STATUS_NO_MEMORY
;
1047 (SEC_DESC
*)(data_set
->data
) = new_sec_desc
;
1049 return NT_STATUS_OK
;
1053 NTSTATUS gums_cs_add_privilege(TALLOC_CTX *mem_ctx, GUMS_COMMIT_SET *com_set, LUID_ATTR priv)
1055 GUMS_DATA_SET *data_set;
1056 LUID_ATTR *new_priv;
1058 if (!mem_ctx || !com_set)
1059 return NT_STATUS_INVALID_PARAMETER;
1061 com_set->count = com_set->count + 1;
1062 if (com_set->count == 1) {
1063 data_set = (GUMS_DATA_SET *)talloc(mem_ctx, sizeof(GUMS_DATA_SET));
1065 data_set = (GUMS_DATA_SET *)talloc_realloc(mem_ctx, com_set->data, sizeof(GUMS_DATA_SET) * com_set->count);
1067 if (data_set == NULL)
1068 return NT_STATUS_NO_MEMORY;
1070 com_set->data[0] = data_set;
1071 data_set = ((com_set->data)[com_set->count - 1]);
1073 data_set->type = GUMS_ADD_PRIVILEGE;
1074 if (NT_STATUS_IS_ERR(dupalloc_luid_attr(mem_ctx, &new_priv, priv)))
1075 return NT_STATUS_NO_MEMORY;
1077 (SEC_DESC *)(data_set->data) = new_priv;
1079 return NT_STATUS_OK;
1082 NTSTATUS gums_cs_del_privilege(TALLOC_CTX *mem_ctx, GUMS_COMMIT_SET *com_set, LUID_ATTR priv)
1084 GUMS_DATA_SET *data_set;
1085 LUID_ATTR *new_priv;
1087 if (!mem_ctx || !com_set)
1088 return NT_STATUS_INVALID_PARAMETER;
1090 com_set->count = com_set->count + 1;
1091 if (com_set->count == 1) {
1092 data_set = (GUMS_DATA_SET *)talloc(mem_ctx, sizeof(GUMS_DATA_SET));
1094 data_set = (GUMS_DATA_SET *)talloc_realloc(mem_ctx, com_set->data, sizeof(GUMS_DATA_SET) * com_set->count);
1096 if (data_set == NULL)
1097 return NT_STATUS_NO_MEMORY;
1099 com_set->data[0] = data_set;
1100 data_set = ((com_set->data)[com_set->count - 1]);
1102 data_set->type = GUMS_DEL_PRIVILEGE;
1103 if (NT_STATUS_IS_ERR(dupalloc_luid_attr(mem_ctx, &new_priv, priv)))
1104 return NT_STATUS_NO_MEMORY;
1106 (SEC_DESC *)(data_set->data) = new_priv;
1108 return NT_STATUS_OK;
1111 NTSTATUS gums_cs_set_privilege_set(TALLOC_CTX *mem_ctx, GUMS_COMMIT_SET *com_set, PRIVILEGE_SET *priv_set)
1113 GUMS_DATA_SET *data_set;
1114 PRIVILEGE_SET *new_priv_set;
1116 if (!mem_ctx || !com_set || !priv_set)
1117 return NT_STATUS_INVALID_PARAMETER;
1119 com_set->count = com_set->count + 1;
1120 if (com_set->count == 1) {
1121 data_set = (GUMS_DATA_SET *)talloc(mem_ctx, sizeof(GUMS_DATA_SET));
1123 data_set = (GUMS_DATA_SET *)talloc_realloc(mem_ctx, com_set->data, sizeof(GUMS_DATA_SET) * com_set->count);
1125 if (data_set == NULL)
1126 return NT_STATUS_NO_MEMORY;
1128 com_set->data[0] = data_set;
1129 data_set = ((com_set->data)[com_set->count - 1]);
1131 data_set->type = GUMS_SET_PRIVILEGE;
1132 if (NT_STATUS_IS_ERR(dup_priv_set(&new_priv_set, mem_ctx, priv_set)))
1133 return NT_STATUS_NO_MEMORY;
1135 (SEC_DESC *)(data_set->data) = new_priv_set;
1137 return NT_STATUS_OK;
1141 NTSTATUS
gums_cs_set_string(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, uint32 type
, char *str
)
1143 GUMS_DATA_SET
*data_set
;
1146 if (!mem_ctx
|| !com_set
|| !str
|| type
< GUMS_SET_NAME
|| type
> GUMS_SET_MUNGED_DIAL
)
1147 return NT_STATUS_INVALID_PARAMETER
;
1149 com_set
->count
= com_set
->count
+ 1;
1150 if (com_set
->count
== 1) { /* first data set */
1151 data_set
= (GUMS_DATA_SET
*)talloc(mem_ctx
, sizeof(GUMS_DATA_SET
));
1153 data_set
= (GUMS_DATA_SET
*)talloc_realloc(mem_ctx
, com_set
->data
, sizeof(GUMS_DATA_SET
) * com_set
->count
);
1155 if (data_set
== NULL
)
1156 return NT_STATUS_NO_MEMORY
;
1158 com_set
->data
[0] = data_set
;
1159 data_set
= ((com_set
->data
)[com_set
->count
- 1]);
1161 data_set
->type
= type
;
1162 new_str
= talloc_strdup(mem_ctx
, str
);
1163 if (new_str
== NULL
)
1164 return NT_STATUS_NO_MEMORY
;
1166 (char *)(data_set
->data
) = new_str
;
1168 return NT_STATUS_OK
;
1171 NTSTATUS
gums_cs_set_name(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, char *name
)
1173 return gums_cs_set_string(mem_ctx
, com_set
, GUMS_SET_NAME
, name
);
1176 NTSTATUS
gums_cs_set_description(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, char *desc
)
1178 return gums_cs_set_string(mem_ctx
, com_set
, GUMS_SET_DESCRIPTION
, desc
);
1181 NTSTATUS
gums_cs_set_full_name(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, char *full_name
)
1183 if (com_set
->type
!= GUMS_OBJ_NORMAL_USER
)
1184 return NT_STATUS_INVALID_PARAMETER
;
1186 return gums_cs_set_string(mem_ctx
, com_set
, GUMS_SET_NAME
, full_name
);
1189 NTSTATUS
gums_cs_set_home_directory(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, char *home_dir
)
1191 if (com_set
->type
!= GUMS_OBJ_NORMAL_USER
)
1192 return NT_STATUS_INVALID_PARAMETER
;
1194 return gums_cs_set_string(mem_ctx
, com_set
, GUMS_SET_NAME
, home_dir
);
1197 NTSTATUS
gums_cs_set_drive(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, char *drive
)
1199 if (com_set
->type
!= GUMS_OBJ_NORMAL_USER
)
1200 return NT_STATUS_INVALID_PARAMETER
;
1202 return gums_cs_set_string(mem_ctx
, com_set
, GUMS_SET_NAME
, drive
);
1205 NTSTATUS
gums_cs_set_logon_script(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, char *logon_script
)
1207 if (com_set
->type
!= GUMS_OBJ_NORMAL_USER
)
1208 return NT_STATUS_INVALID_PARAMETER
;
1210 return gums_cs_set_string(mem_ctx
, com_set
, GUMS_SET_NAME
, logon_script
);
1213 NTSTATUS
gums_cs_set_profile_path(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, char *prof_path
)
1215 if (com_set
->type
!= GUMS_OBJ_NORMAL_USER
)
1216 return NT_STATUS_INVALID_PARAMETER
;
1218 return gums_cs_set_string(mem_ctx
, com_set
, GUMS_SET_NAME
, prof_path
);
1221 NTSTATUS
gums_cs_set_workstations(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, char *wks
)
1223 if (com_set
->type
!= GUMS_OBJ_NORMAL_USER
)
1224 return NT_STATUS_INVALID_PARAMETER
;
1226 return gums_cs_set_string(mem_ctx
, com_set
, GUMS_SET_NAME
, wks
);
1229 NTSTATUS
gums_cs_set_unknown_string(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, char *unkn_str
)
1231 if (com_set
->type
!= GUMS_OBJ_NORMAL_USER
)
1232 return NT_STATUS_INVALID_PARAMETER
;
1234 return gums_cs_set_string(mem_ctx
, com_set
, GUMS_SET_NAME
, unkn_str
);
1237 NTSTATUS
gums_cs_set_munged_dial(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, char *munged_dial
)
1239 if (com_set
->type
!= GUMS_OBJ_NORMAL_USER
)
1240 return NT_STATUS_INVALID_PARAMETER
;
1242 return gums_cs_set_string(mem_ctx
, com_set
, GUMS_SET_NAME
, munged_dial
);
1245 NTSTATUS
gums_cs_set_nttime(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, uint32 type
, NTTIME
*nttime
)
1247 GUMS_DATA_SET
*data_set
;
1250 if (!mem_ctx
|| !com_set
|| !nttime
|| type
< GUMS_SET_LOGON_TIME
|| type
> GUMS_SET_PASS_MUST_CHANGE_TIME
)
1251 return NT_STATUS_INVALID_PARAMETER
;
1253 com_set
->count
= com_set
->count
+ 1;
1254 if (com_set
->count
== 1) { /* first data set */
1255 data_set
= (GUMS_DATA_SET
*)talloc(mem_ctx
, sizeof(GUMS_DATA_SET
));
1257 data_set
= (GUMS_DATA_SET
*)talloc_realloc(mem_ctx
, com_set
->data
, sizeof(GUMS_DATA_SET
) * com_set
->count
);
1259 if (data_set
== NULL
)
1260 return NT_STATUS_NO_MEMORY
;
1262 com_set
->data
[0] = data_set
;
1263 data_set
= ((com_set
->data
)[com_set
->count
- 1]);
1265 data_set
->type
= type
;
1266 new_time
= talloc(mem_ctx
, sizeof(NTTIME
));
1267 if (new_time
== NULL
)
1268 return NT_STATUS_NO_MEMORY
;
1270 new_time
->low
= nttime
->low
;
1271 new_time
->high
= nttime
->high
;
1272 (char *)(data_set
->data
) = new_time
;
1274 return NT_STATUS_OK
;
1277 NTSTATUS
gums_cs_set_logon_time(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, NTTIME
*logon_time
)
1279 if (com_set
->type
!= GUMS_OBJ_NORMAL_USER
)
1280 return NT_STATUS_INVALID_PARAMETER
;
1282 return gums_cs_set_nttime(mem_ctx
, com_set
, GUMS_SET_LOGON_TIME
, logon_time
);
1285 NTSTATUS
gums_cs_set_logoff_time(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, NTTIME
*logoff_time
)
1287 if (com_set
->type
!= GUMS_OBJ_NORMAL_USER
)
1288 return NT_STATUS_INVALID_PARAMETER
;
1290 return gums_cs_set_nttime(mem_ctx
, com_set
, GUMS_SET_LOGOFF_TIME
, logoff_time
);
1293 NTSTATUS
gums_cs_set_kickoff_time(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, NTTIME
*kickoff_time
)
1295 if (com_set
->type
!= GUMS_OBJ_NORMAL_USER
)
1296 return NT_STATUS_INVALID_PARAMETER
;
1298 return gums_cs_set_nttime(mem_ctx
, com_set
, GUMS_SET_KICKOFF_TIME
, kickoff_time
);
1301 NTSTATUS
gums_cs_set_pass_last_set_time(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, NTTIME
*pls_time
)
1303 if (com_set
->type
!= GUMS_OBJ_NORMAL_USER
)
1304 return NT_STATUS_INVALID_PARAMETER
;
1306 return gums_cs_set_nttime(mem_ctx
, com_set
, GUMS_SET_LOGON_TIME
, pls_time
);
1309 NTSTATUS
gums_cs_set_pass_can_change_time(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, NTTIME
*pcc_time
)
1311 if (com_set
->type
!= GUMS_OBJ_NORMAL_USER
)
1312 return NT_STATUS_INVALID_PARAMETER
;
1314 return gums_cs_set_nttime(mem_ctx
, com_set
, GUMS_SET_LOGON_TIME
, pcc_time
);
1317 NTSTATUS
gums_cs_set_pass_must_change_time(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, NTTIME
*pmc_time
)
1319 if (com_set
->type
!= GUMS_OBJ_NORMAL_USER
)
1320 return NT_STATUS_INVALID_PARAMETER
;
1322 return gums_cs_set_nttime(mem_ctx
, com_set
, GUMS_SET_LOGON_TIME
, pmc_time
);
1325 NTSTATUS
gums_cs_add_sids_to_group(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, const DOM_SID
**sids
, const uint32 count
)
1327 GUMS_DATA_SET
*data_set
;
1331 if (!mem_ctx
|| !com_set
|| !sids
)
1332 return NT_STATUS_INVALID_PARAMETER
;
1334 com_set
->count
= com_set
->count
+ 1;
1335 if (com_set
->count
== 1) { /* first data set */
1336 data_set
= (GUMS_DATA_SET
*)talloc(mem_ctx
, sizeof(GUMS_DATA_SET
));
1338 data_set
= (GUMS_DATA_SET
*)talloc_realloc(mem_ctx
, com_set
->data
, sizeof(GUMS_DATA_SET
) * com_set
->count
);
1340 if (data_set
== NULL
)
1341 return NT_STATUS_NO_MEMORY
;
1343 com_set
->data
[0] = data_set
;
1344 data_set
= ((com_set
->data
)[com_set
->count
- 1]);
1346 data_set
->type
= GUMS_ADD_SID_LIST
;
1347 new_sids
= (DOM_SID
**)talloc(mem_ctx
, (sizeof(void *) * count
));
1348 if (new_sids
== NULL
)
1349 return NT_STATUS_NO_MEMORY
;
1350 for (i
= 0; i
< count
; i
++) {
1351 new_sids
[i
] = sid_dup_talloc(mem_ctx
, sids
[i
]);
1352 if (new_sids
[i
] == NULL
)
1353 return NT_STATUS_NO_MEMORY
;
1356 (SEC_DESC
*)(data_set
->data
) = new_sids
;
1358 return NT_STATUS_OK
;
1361 NTSTATUS
gums_cs_add_users_to_group(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, const DOM_SID
**sids
, const uint32 count
)
1363 if (!mem_ctx
|| !com_set
|| !sids
)
1364 return NT_STATUS_INVALID_PARAMETER
;
1365 if (com_set
->type
!= GUMS_OBJ_GROUP
|| com_set
->type
!= GUMS_OBJ_ALIAS
)
1366 return NT_STATUS_INVALID_PARAMETER
;
1368 return gums_cs_add_sids_to_group(mem_ctx
, com_set
, sids
, count
);
1371 NTSTATUS
gums_cs_add_groups_to_group(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, const DOM_SID
**sids
, const uint32 count
)
1373 if (!mem_ctx
|| !com_set
|| !sids
)
1374 return NT_STATUS_INVALID_PARAMETER
;
1375 if (com_set
->type
!= GUMS_OBJ_ALIAS
)
1376 return NT_STATUS_INVALID_PARAMETER
;
1378 return gums_cs_add_sids_to_group(mem_ctx
, com_set
, sids
, count
);
1381 NTSTATUS
gums_cs_del_sids_from_group(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, const DOM_SID
**sids
, const uint32 count
)
1383 GUMS_DATA_SET
*data_set
;
1387 if (!mem_ctx
|| !com_set
|| !sids
)
1388 return NT_STATUS_INVALID_PARAMETER
;
1389 if (com_set
->type
!= GUMS_OBJ_GROUP
|| com_set
->type
!= GUMS_OBJ_ALIAS
)
1390 return NT_STATUS_INVALID_PARAMETER
;
1392 com_set
->count
= com_set
->count
+ 1;
1393 if (com_set
->count
== 1) { /* first data set */
1394 data_set
= (GUMS_DATA_SET
*)talloc(mem_ctx
, sizeof(GUMS_DATA_SET
));
1396 data_set
= (GUMS_DATA_SET
*)talloc_realloc(mem_ctx
, com_set
->data
, sizeof(GUMS_DATA_SET
) * com_set
->count
);
1398 if (data_set
== NULL
)
1399 return NT_STATUS_NO_MEMORY
;
1401 com_set
->data
[0] = data_set
;
1402 data_set
= ((com_set
->data
)[com_set
->count
- 1]);
1404 data_set
->type
= GUMS_DEL_SID_LIST
;
1405 new_sids
= (DOM_SID
**)talloc(mem_ctx
, (sizeof(void *) * count
));
1406 if (new_sids
== NULL
)
1407 return NT_STATUS_NO_MEMORY
;
1408 for (i
= 0; i
< count
; i
++) {
1409 new_sids
[i
] = sid_dup_talloc(mem_ctx
, sids
[i
]);
1410 if (new_sids
[i
] == NULL
)
1411 return NT_STATUS_NO_MEMORY
;
1414 (SEC_DESC
*)(data_set
->data
) = new_sids
;
1416 return NT_STATUS_OK
;
1419 NTSTATUS
gums_ds_set_sids_in_group(TALLOC_CTX
*mem_ctx
, GUMS_COMMIT_SET
*com_set
, const DOM_SID
**sids
, const uint32 count
)
1421 GUMS_DATA_SET
*data_set
;
1425 if (!mem_ctx
|| !com_set
|| !sids
)
1426 return NT_STATUS_INVALID_PARAMETER
;
1427 if (com_set
->type
!= GUMS_OBJ_GROUP
|| com_set
->type
!= GUMS_OBJ_ALIAS
)
1428 return NT_STATUS_INVALID_PARAMETER
;
1430 com_set
->count
= com_set
->count
+ 1;
1431 if (com_set
->count
== 1) { /* first data set */
1432 data_set
= (GUMS_DATA_SET
*)talloc(mem_ctx
, sizeof(GUMS_DATA_SET
));
1434 data_set
= (GUMS_DATA_SET
*)talloc_realloc(mem_ctx
, com_set
->data
, sizeof(GUMS_DATA_SET
) * com_set
->count
);
1436 if (data_set
== NULL
)
1437 return NT_STATUS_NO_MEMORY
;
1439 com_set
->data
[0] = data_set
;
1440 data_set
= ((com_set
->data
)[com_set
->count
- 1]);
1442 data_set
->type
= GUMS_SET_SID_LIST
;
1443 new_sids
= (DOM_SID
**)talloc(mem_ctx
, (sizeof(void *) * count
));
1444 if (new_sids
== NULL
)
1445 return NT_STATUS_NO_MEMORY
;
1446 for (i
= 0; i
< count
; i
++) {
1447 new_sids
[i
] = sid_dup_talloc(mem_ctx
, sids
[i
]);
1448 if (new_sids
[i
] == NULL
)
1449 return NT_STATUS_NO_MEMORY
;
1452 (SEC_DESC
*)(data_set
->data
) = new_sids
;
1454 return NT_STATUS_OK
;
1458 NTSTATUS
gums_commit_data(GUMS_COMMIT_SET
*set
)
1460 return gums_storage
->set_object_values(&(set
->sid
), set
->count
, set
->data
);
1463 NTSTATUS
gums_destroy_commit_set(GUMS_COMMIT_SET
**com_set
)
1465 talloc_destroy((*com_set
)->mem_ctx
);
1468 return NT_STATUS_OK
;