<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Interesting Stuff</title><subtitle type="html" /><id>http://blogs.msdn.com/maxv/atom.xml</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/maxv/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/maxv/atom.xml" /><generator uri="http://communityserver.org" version="2.1.61025.2">Community Server</generator><updated>2008-09-09T21:27:00Z</updated><entry><title>Working with Group Policy Objects Programmatically - Determining registry values to Enable/Disable/Set a specific policy.</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/maxv/archive/2009/07/22/working-with-group-policy-objects-programmatically-determining-registry-values-to-enable-disable-set-a-specific-policy.aspx" /><id>http://blogs.msdn.com/maxv/archive/2009/07/22/working-with-group-policy-objects-programmatically-determining-registry-values-to-enable-disable-set-a-specific-policy.aspx</id><published>2009-07-22T21:43:00Z</published><updated>2009-07-22T21:43:00Z</updated><content type="html">&lt;P&gt;Greetings!&lt;/P&gt;
&lt;P&gt;Over the past few months our team has seen a number of customer requesting information on how to programmatically/create/edit/read registry based GPO information.&amp;nbsp; I took some time to combine a couple of samples into one that illustrates a number of these concepts.&lt;/P&gt;
&lt;P&gt;The first question one must answer when working with a registry based GPO is the programmatic modification of this GPO setting supported by Microsoft.&amp;nbsp; The general answer to that question is that if their exist public documentation on the MSDN or Tech Net site that provides information on the registry key paths and the possible values then, yes, programmatic modification is supported.&amp;nbsp; In my sample, I used the excel spreadsheet available at the following&amp;nbsp;MSDN link:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?familyid=41dc179b-3328-4350-ade1-c0d9289f09ef&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?familyid=41dc179b-3328-4350-ade1-c0d9289f09ef&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?familyid=41dc179b-3328-4350-ade1-c0d9289f09ef&amp;amp;displaylang=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The spreadsheet contains a list of policies and their associated registry keys.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Remember, the GPO can have information stored in 3 different places:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The Active Directory in the form of a GroupPolicyContainer object.&lt;/LI&gt;
&lt;LI&gt;The Sysvol of any DC, where GPO related INI file or POL file is created.&amp;nbsp;&amp;nbsp; The POL file is then&amp;nbsp;written into the local machine registry in either HKEY_LOCAL_MACHINE or&amp;nbsp;HKEY_CURRENT_USER.&amp;nbsp;In addition to these two files, the GPO could store private data in a format known only to the GPO extension.&lt;/LI&gt;
&lt;LI&gt;The client system where a GPO extension could exist to process GPO private data.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;The next step is to determine exactly what values need to be written to the keys in order to enable/disable/set the policy.&amp;nbsp; While the key values are generally documented, there can be subtle differences in the values that the GUI recognizes and uses to determine if a GPO is enable/disable or set.&amp;nbsp; I find that using the empirical method works best to solve this problem.&amp;nbsp;&amp;nbsp; Using the Group Policy Management Console GUI tool, I create a GPO with a specific display name like "MaxVs Test Policy".&amp;nbsp;&amp;nbsp; I set the policy that I want to set programmatically.&amp;nbsp; &amp;nbsp;Then I do a query in the Active Directory Users and computers tool to locate the GPO&amp;nbsp; Object in the Active Directory.&amp;nbsp; The GPO object contains a CN that is a GUID.&amp;nbsp; This GUID can be used to locate the NTFS folder on the SYSVOL of a DC that the policy registry information was written to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;For example, if I created a GPO that sets the "Prevent access to the command prompt" under the "User Configuration" node:&lt;/P&gt;
&lt;P&gt;User Configuration -&amp;gt; Policies -&amp;gt; Administrative Templates -&amp;gt; Security -&amp;gt; "Prevent access to the command prompt"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I enable it and set it.&amp;nbsp; When I click the Apply button, a Registry.POL file will be created on the sysvol in a directory named after the common name of the GroupPolicyContainer object created in the AD.&amp;nbsp; The path will look&amp;nbsp;similar to the following:&lt;/P&gt;
&lt;P&gt;C:\Windows\SYSVOL\sysvol\maxv08.nttest.microsoft.com\Policies\{529AB3E5-3818-42F5-9BDE-95629F33780C}\User&lt;/P&gt;
&lt;P&gt;Where "maxv08.nttest.microsoft.com" will be the domain name of your domain and the GUID string will be the display name of the GPO you just created.&amp;nbsp; At this point, you can view the POL file in notepad or using a binary file editor.&amp;nbsp; If you use notepad, the contents would be similar to the following:&lt;/P&gt;
&lt;P&gt;PReg&#x1;&amp;nbsp;&amp;nbsp; [ S o f t w a r e \ P o l i c i e s \ M i c r o s o f t \ W i n d o w s \ S y s t e m&amp;nbsp;&amp;nbsp; ; D i s a b l e C M D&amp;nbsp;&amp;nbsp; ; &#x4;&amp;nbsp;&amp;nbsp; ; &#x4;&amp;nbsp;&amp;nbsp; ; &#x2;&amp;nbsp;&amp;nbsp; ] &lt;/P&gt;
&lt;P&gt;To see the actual values written in the key, you would need to use a binary editor that displays the binary representation for the values displayed above.&lt;/P&gt;
&lt;P&gt;Copy this file to another location with a name that indicates the setting values.&lt;/P&gt;
&lt;P&gt;Repeat this process for all the settings you wish to duplicate programmatically.&lt;/P&gt;
&lt;P&gt;Once you know the registry values to write, we are ready to write the C++ code to set them.&lt;/P&gt;
&lt;P&gt;Keep watching this blog, I will make another post&amp;nbsp; that provides a function that illustrates how to set the "Prevent access to the command prompt" policy.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9845153" width="1" height="1"&gt;</content><author><name>MaxV@microsoft.com</name><uri>http://blogs.msdn.com/members/MaxV%40microsoft.com.aspx</uri></author><category term="&amp;quot;Group Policy&amp;quot;" scheme="http://blogs.msdn.com/maxv/archive/tags/_2600_quot_3B00_Group+Policy_2600_quot_3B00_/default.aspx" /></entry><entry><title>Creating a new UserPrincipal or GroupPrincipal for existing object when saved causes object to be deleted</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/maxv/archive/2008/09/12/creating-a-new-userprincipal-or-groupprincipal-for-existing-object-when-saved-causes-object-to-be-deleted.aspx" /><id>http://blogs.msdn.com/maxv/archive/2008/09/12/creating-a-new-userprincipal-or-groupprincipal-for-existing-object-when-saved-causes-object-to-be-deleted.aspx</id><published>2008-09-12T21:01:00Z</published><updated>2008-09-12T21:01:00Z</updated><content type="html">&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;We have been&amp;nbsp;encountered a number of issues regarding the System.DirectoryService.Accountmanagement namespace over the&amp;nbsp;&lt;/FONT&gt;&lt;FONT face=Consolas size=3&gt;past few weeks.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;One of these issues is the following:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;FONT face=Consolas size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Consolas size=3&gt;PROBLEM:&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Consolas size=3&gt;=========&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;Suppose you want to create a new principal, pick one: userprincipal or groupprincipal, and that principal already&amp;nbsp;&lt;/FONT&gt;&lt;FONT face=Consolas size=3&gt;exists in your specified context.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;/SPAN&gt;If you use the new operator with the principal, then call the Save method, you&amp;nbsp;will &lt;/FONT&gt;&lt;FONT face=Consolas size=3&gt;receive the following exception:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;"System.DirectoryServices.AccountManagement.PrincipalExistsException: The object already&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Consolas&gt;exists."&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Consolas size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;As a bonus, the namespace will delete the existing object from the Active directory.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;&lt;SPAN style="mso-spacerun: yes"&gt;RESOLUTION:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;&lt;SPAN style="mso-spacerun: yes"&gt;===========&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;This is a known issue with&amp;nbsp;&lt;/FONT&gt;&lt;FONT face=Consolas size=3&gt;the System.DirctoryServices.AccountManagment namespace and will be addressed in a future update/release to the .Net framework.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;WORK AROUND:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;============&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;The simple work around is to test to see if the object exists in the Active Directory before calling the New&amp;nbsp;&lt;/FONT&gt;&lt;FONT face=Consolas size=3&gt;operator to attempt to create a UserPrincipal or GroupPrincipal associated with it.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;Or just use the System.DirectoryServices namespace to create either the user or the group.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Consolas size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Consolas size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Consolas size=3&gt;Steps To Reproduce:&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Consolas size=3&gt;====================&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;The example is using the GroupPrincipal class.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The same issue can be reproduced with using&amp;nbsp;&lt;/FONT&gt;&lt;FONT face=Consolas size=3&gt;the UserPrincipal class.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Consolas size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Consolas size=3&gt;1. Create a simple VB.Net console application and add the following code to the main function:&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Consolas size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Consolas&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;Dim newGroupPrincipal As GroupPrincipal&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Consolas&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;Using ouPrincipalContext As PrincipalContext = New PrincipalContext(ContextType.Domain,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Consolas&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;"MyDomain.Com", "OU=My&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Consolas size=3&gt;Group,DC=MyDomain,DC=Com")&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Consolas size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Consolas&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Try&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Consolas&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;newGroupPrincipal = New GroupPrincipal(ouPrincipalContext)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Consolas&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;With newGroupPrincipal&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Consolas&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;.Name = "test group that will be deleted"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Consolas&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;.IsSecurityGroup = True&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Consolas&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;.GroupScope = GroupScope.Global&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Consolas&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;.SamAccountName = "test group that will be deleted"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Consolas&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;.Save()&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Consolas&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;End With&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Consolas&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Catch ex As Exception&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Consolas&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Debug.WriteLine(ex.ToString)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Consolas&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;End Try&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Consolas&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;End Using&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Consolas size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Consolas size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;2. Run this code twice.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The second time around you will receive the &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Consolas size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;"System.DirectoryServices.AccountManagement.PrincipalExistsException" and you will notice that the principal has&amp;nbsp;&lt;/FONT&gt;&lt;FONT face=Consolas size=3&gt;been deleted.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;/SPAN&gt;3. Run it a third time and the principal will be created anew.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Consolas size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;Stack Trace:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Consolas size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;System.DirectoryServices.AccountManagement.PrincipalExistsException: The object already exists. (Exception from &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Consolas size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;HRESULT: 0x80071392) ---&amp;gt; System.DirectoryServices.DirectoryServicesCOMException (0x80071392): The object already&amp;nbsp;&lt;/FONT&gt;&lt;FONT face=Consolas size=3&gt;exists. (Exception from HRESULT: 0x80071392)&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Consolas&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;at System.DirectoryServices.DirectoryEntry.CommitChanges()&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoPlainText style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Consolas size=3&gt;....&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8947964" width="1" height="1"&gt;</content><author><name>MaxV@microsoft.com</name><uri>http://blogs.msdn.com/members/MaxV%40microsoft.com.aspx</uri></author></entry><entry><title>Who is this Max guy anyway?</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/maxv/archive/2008/09/09/who-is-this-max-guy-anyway.aspx" /><id>http://blogs.msdn.com/maxv/archive/2008/09/09/who-is-this-max-guy-anyway.aspx</id><published>2008-09-09T23:27:00Z</published><updated>2008-09-09T23:27:00Z</updated><content type="html">&lt;P&gt;Greetings!&lt;/P&gt;
&lt;P&gt;Its difficult to know what one should drop into a blog post.&amp;nbsp; I've been told that I should provide a post that states who I am and why the information I might post would be interesting.&lt;/P&gt;
&lt;P&gt;Well.... here it goes:&lt;/P&gt;
&lt;P&gt;I've been working at Microsoft for 14 years, covering the heady days of the Win95 launch all the way through to the present.&amp;nbsp; All 14 years have been spent in the Developer Support organization working with our developer customers.&amp;nbsp; I've supported a number of different Microsoft API sets from the old Lan Man APIs in the late 90's to the new .Net Powershell Automation classes of today.&amp;nbsp; In the early part of my career at Microsoft I was known as the "Thunk Master" working with thunk dlls to call the 16 bit Lan Man APIs&amp;nbsp;from 32 bit Windows 95/98 applications.&lt;/P&gt;
&lt;P&gt;For the past 6 years I have been supporting ADSI and the&amp;nbsp;LDAP API&amp;nbsp;sets. Recently, I've added generic WMI and Powershell to the products I support.&amp;nbsp; If you can do it programmatically with&amp;nbsp; the Active Directory I support it.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;As I find interesting tid bits of information about ADSI/WMI/PSH I'll post them here as a way of documenting them.&lt;/P&gt;
&lt;P&gt;My hope is you will find the information useful and interesting.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8937447" width="1" height="1"&gt;</content><author><name>MaxV@microsoft.com</name><uri>http://blogs.msdn.com/members/MaxV%40microsoft.com.aspx</uri></author></entry></feed>