2 * Unix SMB/CIFS implementation.
3 * Group Policy Object Support
4 * Copyright (C) Guenther Deschner 2005-2008
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 3 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, see <http://www.gnu.org/licenses/>.
21 #include "librpc/gen_ndr/ndr_misc.h"
22 #if _SAMBA_BUILD_ == 4
23 #include "../libgpo/gpo.h"
24 #include "source4/libgpo/ads_convenience.h"
28 #define DEFAULT_DOMAIN_POLICY "Default Domain Policy"
29 #define DEFAULT_DOMAIN_CONTROLLERS_POLICY "Default Domain Controllers Policy"
31 /* should we store a parsed guid ? */
34 const char *guid_string
;
38 static struct gp_table gpo_default_policy
[] = {
39 { DEFAULT_DOMAIN_POLICY
,
40 "31B2F340-016D-11D2-945F-00C04FB984F9" },
41 { DEFAULT_DOMAIN_CONTROLLERS_POLICY
,
42 "6AC1786C-016F-11D2-945F-00C04fB984F9" },
47 /* the following is seen in gPCMachineExtensionNames / gPCUserExtensionNames */
49 static struct gp_table gpo_cse_extensions
[] = {
50 /* used to be "Administrative Templates Extension" */
51 /* "Registry Settings"
52 (http://support.microsoft.com/kb/216357/EN-US/) */
53 { "Registry Settings",
54 GP_EXT_GUID_REGISTRY
},
55 { "Microsoft Disc Quota",
56 "3610EDA5-77EF-11D2-8DC5-00C04FA31A66" },
58 "B1BE8D72-6EAC-11D2-A4EA-00C04F79F83A" },
59 { "Folder Redirection",
60 "25537BA6-77A8-11D2-9B6C-0000F8080861" },
62 "E437BC1C-AA7D-11D2-A382-00C04F991E27" },
63 { "Internet Explorer Branding",
64 "A2E30F80-D7DE-11d2-BBDE-00C04F86AE3B" },
65 { "QoS Packet Scheduler",
66 "426031c0-0b47-4852-b0ca-ac3d37bfcb39" },
68 GP_EXT_GUID_SCRIPTS
},
70 GP_EXT_GUID_SECURITY
},
71 { "Software Installation",
72 "C6DC5466-785A-11D2-84D0-00C04FB169F7" },
73 { "Wireless Group Policy",
74 "0ACDD40C-75AC-BAA0-BF6DE7E7FE63" },
75 { "Application Management",
76 "C6DC5466-785A-11D2-84D0-00C04FB169F7" },
78 "3060E8D0-7020-11D2-842D-00C04FA372D4" },
83 static struct gp_table gpo_cse_snapin_extensions
[] = {
84 { "Administrative Templates",
85 "0F6B957D-509E-11D1-A7CC-0000F87571E3" },
87 "53D6AB1D-2488-11D1-A28C-00C04FB94F17" },
88 { "EFS recovery policy processing",
89 "B1BE8D72-6EAC-11D2-A4EA-00C04F79F83A" },
90 { "Folder Redirection policy processing",
91 "25537BA6-77A8-11D2-9B6C-0000F8080861" },
92 { "Folder Redirection",
93 "88E729D6-BDC1-11D1-BD2A-00C04FB9603F" },
94 { "Registry policy processing",
95 "35378EAC-683F-11D2-A89A-00C04FBBCFA2" },
96 { "Remote Installation Services",
97 "3060E8CE-7020-11D2-842D-00C04FA372D4" },
98 { "Security Settings",
99 "803E14A0-B4FB-11D0-A0D0-00A0C90F574B" },
100 { "Security policy processing",
101 "827D319E-6EAC-11D2-A4EA-00C04F79F83A" },
103 "3060E8D0-7020-11D2-842D-00C04FA372D4" },
105 "53D6AB1B-2488-11D1-A28C-00C04FB94F17" },
109 /****************************************************************
110 ****************************************************************/
112 static const char *name_to_guid_string(const char *name
,
113 struct gp_table
*table
)
117 for (i
= 0; table
[i
].name
; i
++) {
118 if (strequal(name
, table
[i
].name
)) {
119 return table
[i
].guid_string
;
126 /****************************************************************
127 ****************************************************************/
129 static const char *guid_string_to_name(const char *guid_string
,
130 struct gp_table
*table
)
134 for (i
= 0; table
[i
].guid_string
; i
++) {
135 if (strequal(guid_string
, table
[i
].guid_string
)) {
136 return table
[i
].name
;
143 /****************************************************************
144 ****************************************************************/
146 static const char *snapin_guid_string_to_name(const char *guid_string
,
147 struct gp_table
*table
)
150 for (i
= 0; table
[i
].guid_string
; i
++) {
151 if (strequal(guid_string
, table
[i
].guid_string
)) {
152 return table
[i
].name
;
159 static const char *default_gpo_name_to_guid_string(const char *name
)
161 return name_to_guid_string(name
, gpo_default_policy
);
164 static const char *default_gpo_guid_string_to_name(const char *guid
)
166 return guid_string_to_name(guid
, gpo_default_policy
);
170 /****************************************************************
171 ****************************************************************/
173 const char *cse_gpo_guid_string_to_name(const char *guid
)
175 return guid_string_to_name(guid
, gpo_cse_extensions
);
178 /****************************************************************
179 ****************************************************************/
181 const char *cse_gpo_name_to_guid_string(const char *name
)
183 return name_to_guid_string(name
, gpo_cse_extensions
);
186 /****************************************************************
187 ****************************************************************/
189 const char *cse_snapin_gpo_guid_string_to_name(const char *guid
)
191 return snapin_guid_string_to_name(guid
, gpo_cse_snapin_extensions
);
194 /****************************************************************
195 ****************************************************************/
197 void dump_gp_ext(struct GP_EXT
*gp_ext
, int debuglevel
)
199 int lvl
= debuglevel
;
202 if (gp_ext
== NULL
) {
206 DEBUG(lvl
,("\t---------------------\n\n"));
207 DEBUGADD(lvl
,("\tname:\t\t\t%s\n", gp_ext
->gp_extension
));
209 for (i
=0; i
< gp_ext
->num_exts
; i
++) {
211 DEBUGADD(lvl
,("\textension:\t\t\t%s\n",
212 gp_ext
->extensions_guid
[i
]));
213 DEBUGADD(lvl
,("\textension (name):\t\t\t%s\n",
214 gp_ext
->extensions
[i
]));
216 DEBUGADD(lvl
,("\tsnapin:\t\t\t%s\n",
217 gp_ext
->snapins_guid
[i
]));
218 DEBUGADD(lvl
,("\tsnapin (name):\t\t\t%s\n",
219 gp_ext
->snapins
[i
]));
225 /****************************************************************
226 ****************************************************************/
228 void dump_gpo(ADS_STRUCT
*ads
,
230 struct GROUP_POLICY_OBJECT
*gpo
,
233 int lvl
= debuglevel
;
239 DEBUG(lvl
,("---------------------\n\n"));
241 DEBUGADD(lvl
,("name:\t\t\t%s\n", gpo
->name
));
242 DEBUGADD(lvl
,("displayname:\t\t%s\n", gpo
->display_name
));
243 DEBUGADD(lvl
,("version:\t\t%d (0x%08x)\n", gpo
->version
, gpo
->version
));
244 DEBUGADD(lvl
,("version_user:\t\t%d (0x%04x)\n",
245 GPO_VERSION_USER(gpo
->version
),
246 GPO_VERSION_USER(gpo
->version
)));
247 DEBUGADD(lvl
,("version_machine:\t%d (0x%04x)\n",
248 GPO_VERSION_MACHINE(gpo
->version
),
249 GPO_VERSION_MACHINE(gpo
->version
)));
250 DEBUGADD(lvl
,("filesyspath:\t\t%s\n", gpo
->file_sys_path
));
251 DEBUGADD(lvl
,("dspath:\t\t%s\n", gpo
->ds_path
));
253 DEBUGADD(lvl
,("options:\t\t%d ", gpo
->options
));
254 switch (gpo
->options
) {
255 case GPFLAGS_ALL_ENABLED
:
256 DEBUGADD(lvl
,("GPFLAGS_ALL_ENABLED\n"));
258 case GPFLAGS_USER_SETTINGS_DISABLED
:
259 DEBUGADD(lvl
,("GPFLAGS_USER_SETTINGS_DISABLED\n"));
261 case GPFLAGS_MACHINE_SETTINGS_DISABLED
:
262 DEBUGADD(lvl
,("GPFLAGS_MACHINE_SETTINGS_DISABLED\n"));
264 case GPFLAGS_ALL_DISABLED
:
265 DEBUGADD(lvl
,("GPFLAGS_ALL_DISABLED\n"));
268 DEBUGADD(lvl
,("unknown option: %d\n", gpo
->options
));
272 DEBUGADD(lvl
,("link:\t\t\t%s\n", gpo
->link
));
273 DEBUGADD(lvl
,("link_type:\t\t%d ", gpo
->link_type
));
274 switch (gpo
->link_type
) {
276 DEBUGADD(lvl
,("GP_LINK_UNKOWN\n"));
279 DEBUGADD(lvl
,("GP_LINK_OU\n"));
282 DEBUGADD(lvl
,("GP_LINK_DOMAIN\n"));
285 DEBUGADD(lvl
,("GP_LINK_SITE\n"));
287 case GP_LINK_MACHINE
:
288 DEBUGADD(lvl
,("GP_LINK_MACHINE\n"));
294 DEBUGADD(lvl
,("machine_extensions:\t%s\n", gpo
->machine_extensions
));
296 if (gpo
->machine_extensions
) {
298 struct GP_EXT
*gp_ext
= NULL
;
300 if (!ads_parse_gp_ext(mem_ctx
, gpo
->machine_extensions
,
304 dump_gp_ext(gp_ext
, lvl
);
307 DEBUGADD(lvl
,("user_extensions:\t%s\n", gpo
->user_extensions
));
309 if (gpo
->user_extensions
) {
311 struct GP_EXT
*gp_ext
= NULL
;
313 if (!ads_parse_gp_ext(mem_ctx
, gpo
->user_extensions
,
317 dump_gp_ext(gp_ext
, lvl
);
320 DEBUGADD(lvl
,("security descriptor:\n"));
322 NDR_PRINT_DEBUG(security_descriptor
, gpo
->security_descriptor
);
325 /****************************************************************
326 ****************************************************************/
328 void dump_gpo_list(ADS_STRUCT
*ads
,
330 struct GROUP_POLICY_OBJECT
*gpo_list
,
333 struct GROUP_POLICY_OBJECT
*gpo
= NULL
;
335 for (gpo
= gpo_list
; gpo
; gpo
= gpo
->next
) {
336 dump_gpo(ads
, mem_ctx
, gpo
, debuglevel
);
340 /****************************************************************
341 ****************************************************************/
343 void dump_gplink(ADS_STRUCT
*ads
, TALLOC_CTX
*mem_ctx
, struct GP_LINK
*gp_link
)
349 if (gp_link
== NULL
) {
353 DEBUG(lvl
,("---------------------\n\n"));
355 DEBUGADD(lvl
,("gplink: %s\n", gp_link
->gp_link
));
356 DEBUGADD(lvl
,("gpopts: %d ", gp_link
->gp_opts
));
357 switch (gp_link
->gp_opts
) {
358 case GPOPTIONS_INHERIT
:
359 DEBUGADD(lvl
,("GPOPTIONS_INHERIT\n"));
361 case GPOPTIONS_BLOCK_INHERITANCE
:
362 DEBUGADD(lvl
,("GPOPTIONS_BLOCK_INHERITANCE\n"));
368 DEBUGADD(lvl
,("num links: %d\n", gp_link
->num_links
));
370 for (i
= 0; i
< gp_link
->num_links
; i
++) {
372 DEBUGADD(lvl
,("---------------------\n\n"));
374 DEBUGADD(lvl
,("link: #%d\n", i
+ 1));
375 DEBUGADD(lvl
,("name: %s\n", gp_link
->link_names
[i
]));
377 DEBUGADD(lvl
,("opt: %d ", gp_link
->link_opts
[i
]));
378 if (gp_link
->link_opts
[i
] & GPO_LINK_OPT_ENFORCED
) {
379 DEBUGADD(lvl
,("GPO_LINK_OPT_ENFORCED "));
381 if (gp_link
->link_opts
[i
] & GPO_LINK_OPT_DISABLED
) {
382 DEBUGADD(lvl
,("GPO_LINK_OPT_DISABLED"));
384 DEBUGADD(lvl
,("\n"));
386 if (ads
!= NULL
&& mem_ctx
!= NULL
) {
388 struct GROUP_POLICY_OBJECT gpo
;
390 status
= ads_get_gpo(ads
, mem_ctx
,
391 gp_link
->link_names
[i
],
393 if (!ADS_ERR_OK(status
)) {
394 DEBUG(lvl
,("get gpo for %s failed: %s\n",
395 gp_link
->link_names
[i
],
396 ads_errstr(status
)));
399 dump_gpo(ads
, mem_ctx
, &gpo
, lvl
);
404 #endif /* HAVE_LDAP */
406 /****************************************************************
407 ****************************************************************/
409 static bool gpo_get_gp_ext_from_gpo(TALLOC_CTX
*mem_ctx
,
411 struct GROUP_POLICY_OBJECT
*gpo
,
412 struct GP_EXT
**gp_ext
)
414 ZERO_STRUCTP(*gp_ext
);
416 if (flags
& GPO_INFO_FLAG_MACHINE
) {
418 if (gpo
->machine_extensions
) {
420 if (!ads_parse_gp_ext(mem_ctx
, gpo
->machine_extensions
,
427 if (gpo
->user_extensions
) {
429 if (!ads_parse_gp_ext(mem_ctx
, gpo
->user_extensions
,
439 /****************************************************************
440 ****************************************************************/
442 ADS_STATUS
gpo_process_a_gpo(ADS_STRUCT
*ads
,
444 const struct nt_user_token
*token
,
445 struct registry_key
*root_key
,
446 struct GROUP_POLICY_OBJECT
*gpo
,
447 const char *extension_guid_filter
,
450 struct GP_EXT
*gp_ext
= NULL
;
453 DEBUG(10,("gpo_process_a_gpo: processing gpo %s (%s)\n",
454 gpo
->name
, gpo
->display_name
));
455 if (extension_guid_filter
) {
456 DEBUGADD(10,("gpo_process_a_gpo: using filter %s (%s)\n",
457 extension_guid_filter
,
458 cse_gpo_guid_string_to_name(extension_guid_filter
)));
461 if (!gpo_get_gp_ext_from_gpo(mem_ctx
, flags
, gpo
, &gp_ext
)) {
462 return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER
);
465 if (!gp_ext
|| !gp_ext
->num_exts
) {
466 if (flags
& GPO_INFO_FLAG_VERBOSE
) {
467 DEBUG(0,("gpo_process_a_gpo: "
468 "no policies in %s (%s) for this extension\n",
469 gpo
->name
, gpo
->display_name
));
474 for (i
=0; i
<gp_ext
->num_exts
; i
++) {
478 if (extension_guid_filter
&&
479 !strequal(extension_guid_filter
,
480 gp_ext
->extensions_guid
[i
])) {
484 ntstatus
= gpext_process_extension(ads
, mem_ctx
,
485 flags
, token
, root_key
, gpo
,
486 gp_ext
->extensions_guid
[i
],
487 gp_ext
->snapins_guid
[i
]);
488 if (!NT_STATUS_IS_OK(ntstatus
)) {
489 ADS_ERROR_NT(ntstatus
);
496 /****************************************************************
497 ****************************************************************/
499 static ADS_STATUS
gpo_process_gpo_list_by_ext(ADS_STRUCT
*ads
,
501 const struct nt_user_token
*token
,
502 struct registry_key
*root_key
,
503 struct GROUP_POLICY_OBJECT
*gpo_list
,
504 const char *extensions_guid
,
508 struct GROUP_POLICY_OBJECT
*gpo
;
510 for (gpo
= gpo_list
; gpo
; gpo
= gpo
->next
) {
512 if (gpo
->link_type
== GP_LINK_LOCAL
) {
517 /* FIXME: we need to pass down the *list* down to the
518 * extension, otherwise we cannot store the e.g. the *list* of
519 * logon-scripts correctly (for more then one GPO) */
521 status
= gpo_process_a_gpo(ads
, mem_ctx
, token
, root_key
,
522 gpo
, extensions_guid
, flags
);
524 if (!ADS_ERR_OK(status
)) {
525 DEBUG(0,("failed to process gpo by ext: %s\n",
526 ads_errstr(status
)));
534 /****************************************************************
535 ****************************************************************/
537 ADS_STATUS
gpo_process_gpo_list(ADS_STRUCT
*ads
,
539 const struct nt_user_token
*token
,
540 struct GROUP_POLICY_OBJECT
*gpo_list
,
541 const char *extensions_guid_filter
,
544 ADS_STATUS status
= ADS_SUCCESS
;
545 struct gp_extension
*gp_ext_list
= NULL
;
546 struct gp_extension
*gp_ext
= NULL
;
547 struct registry_key
*root_key
= NULL
;
548 struct gp_registry_context
*reg_ctx
= NULL
;
551 status
= ADS_ERROR_NT(init_gp_extensions(mem_ctx
));
552 if (!ADS_ERR_OK(status
)) {
556 gp_ext_list
= get_gp_extension_list();
558 return ADS_ERROR_NT(NT_STATUS_DLL_INIT_FAILED
);
561 /* get the key here */
562 if (flags
& GPO_LIST_FLAG_MACHINE
) {
563 werr
= gp_init_reg_ctx(mem_ctx
, KEY_HKLM
, REG_KEY_WRITE
,
567 werr
= gp_init_reg_ctx(mem_ctx
, KEY_HKCU
, REG_KEY_WRITE
,
571 if (!W_ERROR_IS_OK(werr
)) {
572 gp_free_reg_ctx(reg_ctx
);
573 return ADS_ERROR_NT(werror_to_ntstatus(werr
));
576 root_key
= reg_ctx
->curr_key
;
578 for (gp_ext
= gp_ext_list
; gp_ext
; gp_ext
= gp_ext
->next
) {
580 const char *guid_str
= NULL
;
582 guid_str
= GUID_string(mem_ctx
, gp_ext
->guid
);
584 status
= ADS_ERROR_NT(NT_STATUS_NO_MEMORY
);
588 if (extensions_guid_filter
&&
589 (!strequal(guid_str
, extensions_guid_filter
))) {
593 DEBUG(0,("-------------------------------------------------\n"));
594 DEBUG(0,("gpo_process_gpo_list: processing ext: %s {%s}\n",
595 gp_ext
->name
, guid_str
));
598 status
= gpo_process_gpo_list_by_ext(ads
, mem_ctx
, token
,
601 if (!ADS_ERR_OK(status
)) {
607 gp_free_reg_ctx(reg_ctx
);
608 talloc_free(root_key
);
609 free_gp_extensions();
615 /****************************************************************
616 check wether the version number in a GROUP_POLICY_OBJECT match those of the
617 locally stored version. If not, fetch the required policy via CIFS
618 ****************************************************************/
620 NTSTATUS
check_refresh_gpo(ADS_STRUCT
*ads
,
623 struct GROUP_POLICY_OBJECT
*gpo
,
624 struct cli_state
**cli_out
)
629 char *nt_path
= NULL
;
630 char *unix_path
= NULL
;
631 uint32_t sysvol_gpt_version
= 0;
632 char *display_name
= NULL
;
633 struct cli_state
*cli
= NULL
;
635 result
= gpo_explode_filesyspath(mem_ctx
, gpo
->file_sys_path
,
636 &server
, &share
, &nt_path
, &unix_path
);
638 if (!NT_STATUS_IS_OK(result
)) {
642 result
= gpo_get_sysvol_gpt_version(mem_ctx
,
646 if (!NT_STATUS_IS_OK(result
) &&
647 !NT_STATUS_EQUAL(result
, NT_STATUS_NO_SUCH_FILE
)) {
648 DEBUG(10,("check_refresh_gpo: "
649 "failed to get local gpt version: %s\n",
654 DEBUG(10,("check_refresh_gpo: versions gpo %d sysvol %d\n",
655 gpo
->version
, sysvol_gpt_version
));
657 /* FIXME: handle GPO_INFO_FLAG_FORCED_REFRESH from flags */
659 while (gpo
->version
> sysvol_gpt_version
) {
661 DEBUG(1,("check_refresh_gpo: need to refresh GPO\n"));
663 if (*cli_out
== NULL
) {
665 result
= cli_full_connection(&cli
,
667 ads_get_ldap_server_name(ads
),
671 ads
->auth
.user_name
, NULL
,
673 CLI_FULL_CONNECTION_USE_KERBEROS
|
674 CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS
,
676 if (!NT_STATUS_IS_OK(result
)) {
677 DEBUG(10,("check_refresh_gpo: "
678 "failed to connect: %s\n",
686 result
= gpo_fetch_files(mem_ctx
, *cli_out
, gpo
);
687 if (!NT_STATUS_IS_OK(result
)) {
691 result
= gpo_get_sysvol_gpt_version(mem_ctx
,
695 if (!NT_STATUS_IS_OK(result
)) {
696 DEBUG(10,("check_refresh_gpo: "
697 "failed to get local gpt version: %s\n",
702 if (gpo
->version
== sysvol_gpt_version
) {
707 DEBUG(10,("Name:\t\t\t%s (%s)\n", gpo
->display_name
, gpo
->name
));
708 DEBUGADD(10,("sysvol GPT version:\t%d (user: %d, machine: %d)\n",
710 GPO_VERSION_USER(sysvol_gpt_version
),
711 GPO_VERSION_MACHINE(sysvol_gpt_version
)));
712 DEBUGADD(10,("LDAP GPO version:\t%d (user: %d, machine: %d)\n",
714 GPO_VERSION_USER(gpo
->version
),
715 GPO_VERSION_MACHINE(gpo
->version
)));
716 DEBUGADD(10,("LDAP GPO link:\t\t%s\n", gpo
->link
));
718 result
= NT_STATUS_OK
;
725 /****************************************************************
726 check wether the version numbers in the gpo_list match the locally stored, if
727 not, go and get each required GPO via CIFS
728 ****************************************************************/
730 NTSTATUS
check_refresh_gpo_list(ADS_STRUCT
*ads
,
733 struct GROUP_POLICY_OBJECT
*gpo_list
)
735 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
736 struct cli_state
*cli
= NULL
;
737 struct GROUP_POLICY_OBJECT
*gpo
;
740 return NT_STATUS_INVALID_PARAMETER
;
743 for (gpo
= gpo_list
; gpo
; gpo
= gpo
->next
) {
745 result
= check_refresh_gpo(ads
, mem_ctx
, flags
, gpo
, &cli
);
746 if (!NT_STATUS_IS_OK(result
)) {
751 result
= NT_STATUS_OK
;
761 /****************************************************************
762 ****************************************************************/
764 NTSTATUS
gpo_get_unix_path(TALLOC_CTX
*mem_ctx
,
765 struct GROUP_POLICY_OBJECT
*gpo
,
768 char *server
, *share
, *nt_path
;
769 return gpo_explode_filesyspath(mem_ctx
, gpo
->file_sys_path
,
770 &server
, &share
, &nt_path
, unix_path
);
773 /****************************************************************
774 ****************************************************************/
776 char *gpo_flag_str(uint32_t flags
)
784 if (flags
& GPO_INFO_FLAG_SLOWLINK
)
785 fstrcat(str
, "GPO_INFO_FLAG_SLOWLINK ");
786 if (flags
& GPO_INFO_FLAG_VERBOSE
)
787 fstrcat(str
, "GPO_INFO_FLAG_VERBOSE ");
788 if (flags
& GPO_INFO_FLAG_SAFEMODE_BOOT
)
789 fstrcat(str
, "GPO_INFO_FLAG_SAFEMODE_BOOT ");
790 if (flags
& GPO_INFO_FLAG_NOCHANGES
)
791 fstrcat(str
, "GPO_INFO_FLAG_NOCHANGES ");
792 if (flags
& GPO_INFO_FLAG_MACHINE
)
793 fstrcat(str
, "GPO_INFO_FLAG_MACHINE ");
794 if (flags
& GPO_INFO_FLAG_LOGRSOP_TRANSITION
)
795 fstrcat(str
, "GPO_INFO_FLAG_LOGRSOP_TRANSITION ");
796 if (flags
& GPO_INFO_FLAG_LINKTRANSITION
)
797 fstrcat(str
, "GPO_INFO_FLAG_LINKTRANSITION ");
798 if (flags
& GPO_INFO_FLAG_FORCED_REFRESH
)
799 fstrcat(str
, "GPO_INFO_FLAG_FORCED_REFRESH ");
800 if (flags
& GPO_INFO_FLAG_BACKGROUND
)
801 fstrcat(str
, "GPO_INFO_FLAG_BACKGROUND ");
806 /****************************************************************
807 ****************************************************************/
809 NTSTATUS
gp_find_file(TALLOC_CTX
*mem_ctx
,
811 const char *filename
,
813 const char **filename_out
)
815 const char *tmp
= NULL
;
817 const char *path
= NULL
;
819 if (flags
& GPO_LIST_FLAG_MACHINE
) {
825 tmp
= talloc_asprintf(mem_ctx
, "%s/%s/%s", filename
,
827 NT_STATUS_HAVE_NO_MEMORY(tmp
);
829 if (stat(tmp
, &sbuf
) == 0) {
834 path
= talloc_strdup_upper(mem_ctx
, path
);
835 NT_STATUS_HAVE_NO_MEMORY(path
);
837 tmp
= talloc_asprintf(mem_ctx
, "%s/%s/%s", filename
,
839 NT_STATUS_HAVE_NO_MEMORY(tmp
);
841 if (stat(tmp
, &sbuf
) == 0) {
846 return NT_STATUS_NO_SUCH_FILE
;
849 /****************************************************************
850 ****************************************************************/
852 ADS_STATUS
gp_get_machine_token(ADS_STRUCT
*ads
,
855 struct nt_user_token
**token
)
857 struct nt_user_token
*ad_token
= NULL
;
862 return ADS_ERROR_NT(NT_STATUS_NOT_SUPPORTED
);
864 status
= ads_get_sid_token(ads
, mem_ctx
, dn
, &ad_token
);
865 if (!ADS_ERR_OK(status
)) {
869 ntstatus
= merge_nt_token(mem_ctx
, ad_token
, get_system_token(),
871 if (!NT_STATUS_IS_OK(ntstatus
)) {
872 return ADS_ERROR_NT(ntstatus
);