<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Create a Local Windows User Account [C#/.NET]</title>
	<atom:link href="http://www.thejackol.com/2004/08/03/create-a-local-windows-user-account-cnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thejackol.com/2004/08/03/create-a-local-windows-user-account-cnet/</link>
	<description>01100010 01101100 01100101 01101000</description>
	<lastBuildDate>Thu, 29 Jul 2010 17:48:46 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: jack</title>
		<link>http://www.thejackol.com/2004/08/03/create-a-local-windows-user-account-cnet/comment-page-1/#comment-217938</link>
		<dc:creator>jack</dc:creator>
		<pubDate>Sat, 17 Oct 2009 11:32:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.thejackol.com/?p=35#comment-217938</guid>
		<description>brilliant help</description>
		<content:encoded><![CDATA[<p>brilliant help</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lunkan</title>
		<link>http://www.thejackol.com/2004/08/03/create-a-local-windows-user-account-cnet/comment-page-1/#comment-217623</link>
		<dc:creator>Lunkan</dc:creator>
		<pubDate>Tue, 13 Oct 2009 09:55:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.thejackol.com/?p=35#comment-217623</guid>
		<description>Regarding the new user not showing up in the &quot;Users Tab&quot; in the control panel. This is because the user does not belong to any groups. Don&#039;t fret this is easily accomplished. Using Marks Code here:

PrincipalContext pc = new PrincipalContext(ContextType.Machine);
System.DirectoryServices.AccountManagement.UserPrincipal u = new UserPrincipal(pc);
u.SetPassword(password);
u.Name = username;
u.Description = description;
u.UserCannotChangePassword = true;
u.PasswordNeverExpires = true;
u.Save();

Now to add this user to the &quot;Users&quot; group so the new entry shows up under users do this:

GroupPrincipal gPc = GroupPrincipal.FindByIdentity(pc, &quot;Users&quot;);
gPc.Members.Add(u);
gPc.Save();

Voila now the user shows up in the control panel.</description>
		<content:encoded><![CDATA[<p>Regarding the new user not showing up in the &#8220;Users Tab&#8221; in the control panel. This is because the user does not belong to any groups. Don&#8217;t fret this is easily accomplished. Using Marks Code here:</p>
<p>PrincipalContext pc = new PrincipalContext(ContextType.Machine);<br />
System.DirectoryServices.AccountManagement.UserPrincipal u = new UserPrincipal(pc);<br />
u.SetPassword(password);<br />
u.Name = username;<br />
u.Description = description;<br />
u.UserCannotChangePassword = true;<br />
u.PasswordNeverExpires = true;<br />
u.Save();</p>
<p>Now to add this user to the &#8220;Users&#8221; group so the new entry shows up under users do this:</p>
<p>GroupPrincipal gPc = GroupPrincipal.FindByIdentity(pc, &#8220;Users&#8221;);<br />
gPc.Members.Add(u);<br />
gPc.Save();</p>
<p>Voila now the user shows up in the control panel.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aditya Bhave</title>
		<link>http://www.thejackol.com/2004/08/03/create-a-local-windows-user-account-cnet/comment-page-1/#comment-214458</link>
		<dc:creator>Aditya Bhave</dc:creator>
		<pubDate>Wed, 02 Sep 2009 23:03:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.thejackol.com/?p=35#comment-214458</guid>
		<description>The new account with Dan&#039;s code does not come up in User Accounts in Control Panel. How can it be done?</description>
		<content:encoded><![CDATA[<p>The new account with Dan&#8217;s code does not come up in User Accounts in Control Panel. How can it be done?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fouine</title>
		<link>http://www.thejackol.com/2004/08/03/create-a-local-windows-user-account-cnet/comment-page-1/#comment-183523</link>
		<dc:creator>fouine</dc:creator>
		<pubDate>Sat, 06 Dec 2008 19:47:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.thejackol.com/?p=35#comment-183523</guid>
		<description>dtp,
Before posting on a forum, just make sure you know what you are talking about which is obviously not the case, otherwise you would know that &quot;\\&quot; is equivalent to @&quot;\&quot;</description>
		<content:encoded><![CDATA[<p>dtp,<br />
Before posting on a forum, just make sure you know what you are talking about which is obviously not the case, otherwise you would know that &#8220;&#92;&#8221; is equivalent to @&#8221;\&#8221; </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MD</title>
		<link>http://www.thejackol.com/2004/08/03/create-a-local-windows-user-account-cnet/comment-page-1/#comment-105421</link>
		<dc:creator>MD</dc:creator>
		<pubDate>Sun, 10 Feb 2008 01:30:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.thejackol.com/?p=35#comment-105421</guid>
		<description>Brilliant Mark, absolutely brilliant. Using System.DirectoryServices.AccountManagement really simplifies the process. Thanks for the code... I just had to put quotes on the username, description and password.</description>
		<content:encoded><![CDATA[<p>Brilliant Mark, absolutely brilliant. Using System.DirectoryServices.AccountManagement really simplifies the process. Thanks for the code&#8230; I just had to put quotes on the username, description and password.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://www.thejackol.com/2004/08/03/create-a-local-windows-user-account-cnet/comment-page-1/#comment-100891</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Wed, 23 Jan 2008 00:35:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.thejackol.com/?p=35#comment-100891</guid>
		<description>Looks like the System.DirectoryServices.AccountManagement namespace is only available in .Net 3.5.

Dan&#039;s CreateLocalUser method looks like pretty good option for non .Net 3.5 users.</description>
		<content:encoded><![CDATA[<p>Looks like the System.DirectoryServices.AccountManagement namespace is only available in .Net 3.5.</p>
<p>Dan&#8217;s CreateLocalUser method looks like pretty good option for non .Net 3.5 users.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Lambert</title>
		<link>http://www.thejackol.com/2004/08/03/create-a-local-windows-user-account-cnet/comment-page-1/#comment-90798</link>
		<dc:creator>Mark Lambert</dc:creator>
		<pubDate>Fri, 30 Nov 2007 10:09:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.thejackol.com/?p=35#comment-90798</guid>
		<description>or you can use
using System.DirectoryServices.AccountManagement;

then it is even more straight forward.

			PrincipalContext pc = new PrincipalContext(ContextType.Machine);
			System.DirectoryServices.AccountManagement.UserPrincipal u = new UserPrincipal(pc);
			u.SetPassword(password);
			u.Name = username;
			u.Description = description;
			u.UserCannotChangePassword = true;
			u.PasswordNeverExpires = true;
			u.Save();</description>
		<content:encoded><![CDATA[<p>or you can use<br />
using System.DirectoryServices.AccountManagement;</p>
<p>then it is even more straight forward.</p>
<p>			PrincipalContext pc = new PrincipalContext(ContextType.Machine);<br />
			System.DirectoryServices.AccountManagement.UserPrincipal u = new UserPrincipal(pc);<br />
			u.SetPassword(password);<br />
			u.Name = username;<br />
			u.Description = description;<br />
			u.UserCannotChangePassword = true;<br />
			u.PasswordNeverExpires = true;<br />
			u.Save();</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dtp</title>
		<link>http://www.thejackol.com/2004/08/03/create-a-local-windows-user-account-cnet/comment-page-1/#comment-42769</link>
		<dc:creator>dtp</dc:creator>
		<pubDate>Tue, 23 Jan 2007 21:37:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.thejackol.com/?p=35#comment-42769</guid>
		<description>Also windows paths in C# need to have the backslashes escaped as in C:\\WINNT\\...</description>
		<content:encoded><![CDATA[<p>Also windows paths in C# need to have the backslashes escaped as in C:&#92;WINNT&#92;&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
