Exemple #1
0
 /// <summary>
 /// Opens the default GPO for the specified remote computer
 /// </summary>
 /// <param name="computerName">Name of the remote computer in the format "\\ComputerName"</param>
 public ComputerGroupPolicyObject(string computerName, GroupPolicyObjectSettings options = null)
 {
     options = options ?? new GroupPolicyObjectSettings();
     trycatch(() => instance.OpenRemoteMachineGPO(computerName, options.Flag),
              "Unable to open GPO on remote machine '{0}'", computerName);
     IsLocal = false;
 }
Exemple #2
0
 /// <summary>
 /// Opens the default GPO for the local computer
 /// </summary>
 public ComputerGroupPolicyObject(GroupPolicyObjectSettings options = null)
 {
     options = options ?? new GroupPolicyObjectSettings();
     trycatch(() => instance.OpenLocalMachineGPO(options.Flag),
              "Unable to open local machine GPO");
     IsLocal = true;
 }
Exemple #3
0
        /// <summary>
        /// Creates a new GPO in the Active Directory with the specified display name and opens
        /// it with the given settings.
        /// </summary>
        /// <param name="activeDirectoryPath">
        /// Specifies the Active Directory path of the object to create.
        /// If the path specifies a domain controller, the GPO is created on that DC.
        /// Otherwise, the system will select a DC on the caller's behalf.
        /// </param>
        /// <param name="displayName">Specifies the display name of the object to create.</param>
        public static ActiveDirectoryGroupPolicyObject Create(string activeDirectoryPath, string displayName,
                                                              GroupPolicyObjectSettings settings = null)
        {
            settings = new GroupPolicyObjectSettings();
            var instance = getInstance();

            trycatch(() => instance.New(activeDirectoryPath, displayName, settings.Flag),
                     "Unable to create new GPO instance with path '{0}' and display name '{1}'",
                     activeDirectoryPath, displayName);
            return(new ActiveDirectoryGroupPolicyObject(instance));
        }
Exemple #4
0
 /// <summary>
 /// Opens the specified GPO as determined by the path
 /// </summary>
 /// <param name="activeDirectoryPath">
 /// Specifies the Active Directory path of the object to open.
 /// If the path specifies a domain controller, the GPO is created on that DC.
 /// Otherwise, the system will select a DC on the caller's behalf.
 /// </param>
 public ActiveDirectoryGroupPolicyObject(string activeDirectoryPath, GroupPolicyObjectSettings settings = null)
 {
     settings = new GroupPolicyObjectSettings();
     trycatch(() => instance.OpenDSGPO(activeDirectoryPath, settings.Flag),
              "Unable to open GPO at ActiveDirectory path '{0}'", activeDirectoryPath);
 }