Click here to Skip to main content
15,885,278 members
Articles / Programming Languages / C#
Article

Internet Configuration Manager

Rate me:
Please Sign up or sign in to vote.
4.47/5 (12 votes)
21 Sep 2008CPOL4 min read 33K   689   23  
A simple tool to configure your internet settings
Image 1

Introduction

Group Policy is a feature of Microsoft Windows NT family of operating systems that provides centralized management and configuration of computers and remote users in an Active Directory environment. It is part of Microsoft's IntelliMirror technologies which aim to reduce the overall cost of supporting users of Windows. These technologies relate to management of disconnected machines or roaming users and include Roaming user profiles, Folder redirection and Offline Files.

Although Group Policy is usually used in enterprise environments, its usage is also common in schools, businesses, and other small organizations to restrict certain actions that may pose potential security risks: for instance, blocking the Windows Task Manager, restricting access to certain folders, disabling downloaded executable files and so on.

Background

Group Policy can control a target object's registry, NTFS security, audit and security policy, software installation, logon/logoff scripts, folder redirection, and Internet Explorer settings. The policy settings are stored in Group Policy Objects (GPOs). A GPO is internally referenced by a Globally Unique Identifier (GUID). Each one may be linked to multiple sites, domains or organizational units. This allows for multiple machines or users to be updated via a change to a single GPO in turn reducing the administrative burden and costs associated with managing these resources.

Group Policies use Administrative Templates (ADM/ADMX) files to describe where registry-based policy settings are stored in the registry. Administrative Templates essentially describe the user interface that administrators see in the Group Policy Object Editor snap-in. On a single workstation, administrative templates are stored in the %WinDir%\Inf folder, while on a domain controller, they are stored for each domain GPO in a single folder called the Group Policy Template (GPT) in the Sysvol folder. ADMX is the new XML-based file format introduced in Windows Vista which contains configuration settings for individual GPOs.

User and computer objects may only exist once in the Active Directory but often fall into the scope of several GPOs. The user or computer object applies each applicable GPO. Conflicts between GPOs are resolved at a per attribute level.

Note

Group Policies are analyzed and applied at startup for computers and during logon for users. The client machine refreshes most of the Group Policy settings periodically, the period ranging from 60-120 minutes and controlled by a configurable parameter of the Group Policy settings.

Local Group Policy

We are specifically concerned about LGP in this article. Local group policy (LGP) is a more basic version of the group policy used by Active Directory. In versions of Windows before Windows Vista, LGP can configure the group policy for a single local computer, but unlike Active Directory group policy, cannot make policies for individual users or groups. It also has fewer options overall than Active Directory group policy. The specific-user limitation can be overcome by using the Registry Editor to make changes under the HKCU or HKU keys. LGP simply makes registry changes under the HKLM key, thus affecting all users; the same changes can be made under HKCU or HKU to only affect certain users. Microsoft has more information on using the Registry Editor to configure group policy available on TechNet. LGP can be used on a computer on a domain, and it can be used on Windows XP Home Edition.

Windows Vista supports Multiple Local Group Policy objects (MLGPO), which allows setting local group policy for individual users.

Advanced Group Policy Management (AGPM)

The Advanced Group Policy Management (AGPM) increases the capabilities of the Group Policy Management Console (GPMC), providing:

  • Standard roles for delegating permissions to manage Group Policy objects (GPOs) to multiple Group Policy administrators.
  • An archive to enable Group Policy administrators to create and modify GPOs offline before deploying them to a production environment.
  • The ability to roll back to any previous version of a GPO.
  • Check-in/check-out capability for GPOs to ensure that Group Policy administrators do not overwrite each other's work.

Image 2

Some features include:

  • Offline editing of GPOs
  • Difference reporting and audit logging
  • Recovery of a deleted GPO (Recycle Bin)
  • Repair of live GPOs 
  • Creation of GPO template libraries
  • Subscription to policy change e-mail notifications
  • Version tracking, history capture, and quick rollback of deployed changes
  • Role-based administration (Editor, Reviewer, Approver)
  • Change request approval

The Code

In this application, we are editing the values of the registry key.

HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings affecting the LGP settings of the current logged user:

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using Microsoft.Win32;
using System.Windows.Forms;

namespace Internet_configuration_manager
{
    public partial class Form1 : Form
    {
        RegistryKey key;
        public Form1()
        {
            InitializeComponent();
            key = Registry.CurrentUser.OpenSubKey(
	    "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
        }

        private void btn_RestoreDefaults_Click(object sender, EventArgs e)
        {
            ch_AutoRedial.Checked = false;
            ch_EnableAdvancedPrivacy.Checked = false;
            ch_EnableProxy.Checked = false;
            ch_MegrateProxy.Checked = true;
            ch_EnableNegotiate.Checked = true;
            ch_EnableHttp1_1.Checked = true;

            txtEmailName.Text = @"IEUser@";
            if (combo_AutoConfigProxy.Items[0].ToString() != "wininet.dll")
                combo_AutoConfigProxy.Items.Add("wininet.dll");
            combo_AutoConfigProxy.Text = @"wininet.dll";            

            updateRegKey();
        }

        private void btn_Discard_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void updateRegKey()
        {
            try
            {
                key.SetValue("ProxyEnable", ch_EnableProxy.Checked == true ? 1 : 0);
                key.SetValue("MigrateProxy", ch_MegrateProxy.Checked == true ? 1 : 0);
                
                key.SetValue("PrivacyAdvanced", 
			ch_EnableAdvancedPrivacy.Checked == true ? 1 : 0);
                key.SetValue("EnableNegotiate", 
			ch_EnableNegotiate.Checked == true ? 1 : 0);
                
                key.SetValue("EnableHttp1_1", ch_EnableHttp1_1.Checked == true ? 1 : 0);
                key.SetValue("NoNetAutodial", ch_AutoRedial.Checked == true ? 1 : 0);

                key.SetValue("AutoConfigProxy", combo_AutoConfigProxy.Text);
                key.SetValue("EmailName", txtEmailName.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not save all settings.\n"+ex.Message, 
			"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void btn_Save_Click(object sender, EventArgs e)
        {
            updateRegKey();
            MessageBox.Show("Settings Saved!", "Success", 
		MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                ch_EnableProxy.Checked = (int)key.GetValue("ProxyEnable") == 1 ? 
							true : false;
                ch_MegrateProxy.Checked = (int)key.GetValue("MigrateProxy") == 0 ? 
							false : true;

                ch_EnableAdvancedPrivacy.Checked = 
		(int)key.GetValue("PrivacyAdvanced") == 0 ? false : true;
                ch_EnableNegotiate.Checked = 
		(int)key.GetValue("EnableNegotiate") == 0 ? false : true;
                
                ch_EnableHttp1_1.Checked = 
		(int)key.GetValue("EnableHttp1_1") == 0 ? false : true;
                ch_AutoRedial.Checked = 
		(int)key.GetValue("NoNetAutodial") == 0 ? false : true;

                combo_AutoConfigProxy.Items.Add(key.GetValue("AutoConfigProxy"));
                if(combo_AutoConfigProxy.Items[0].ToString()!= "wininet.dll")
                combo_AutoConfigProxy.Items.Add("wininet.dll");
                combo_AutoConfigProxy.Text = (string)key.GetValue("AutoConfigProxy");

                lblBrowser.Text = (string)key.GetValue("User Agent");
                txtEmailName.Text = (string)key.GetValue("EmailName");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error loading settings\n"+ex.Message, 
			"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            
        }
//By Muammar Yacoob

Points of Interest

In Microsoft Windows XP SP 1, this can actually override the LGP settings set by your administrator!

History

  • 21st September, 2008: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Retired QSoft
Yemen Yemen
Biography?! I'm not dead yet!
www.QSoftOnline.com

Comments and Discussions

 
-- There are no messages in this forum --