|
Posted by =?Utf-8?B?TWR1Zm91cg==?= on April 24, 2007, 8:02 am
If you were Registered and logged in, you could reply and use other advanced thread options
Hi,
I need to create local user accounts in windows (2000 or 2003) from an
ASP.NET page.
Our internal web server works with windows autentification and i am building
a user manager page. It need to add, modifiy and disable account local to the
machine.
Can anyone put me on a track?
Thank you
|
|
Posted by on April 24, 2007, 6:41 pm
If you were Registered and logged in, you could reply and use other advanced thread options
Hello,
I am happy to put you on the right track. I have built similar web
apps before. Are you using C# or Vb.net? Is there a particular
challenge you are facing, or are you looking for general information?
J Wolfgang Goerlich
> Hi,
> I need to create local user accounts in windows (2000 or 2003) from an
> ASP.NET page.
>
> Our internal web server works with windows autentification and i am building
> a user manager page. It need to add, modifiy and disable account local to the
> machine.
>
> Can anyone put me on a track?
>
> Thank you
|
|
Posted by =?Utf-8?B?TWR1Zm91cg==?= on April 24, 2007, 8:48 pm
If you were Registered and logged in, you could reply and use other advanced thread options Thank you for your answer.
I need to know how to create the local user in windows from ASP.NET C#.
I read about the DirectoryEntry but the example i found did not work.
The interface is pretty much done as we are currenttly using perl to do this
but i would like to change it to C#.
"jwgoerlich@gmail.com" wrote:
> Hello,
>
> I am happy to put you on the right track. I have built similar web
> apps before. Are you using C# or Vb.net? Is there a particular
> challenge you are facing, or are you looking for general information?
>
> J Wolfgang Goerlich
>
>
> > Hi,
> > I need to create local user accounts in windows (2000 or 2003) from an
> > ASP.NET page.
> >
> > Our internal web server works with windows autentification and i am building
> > a user manager page. It need to add, modifiy and disable account local to the
> > machine.
> >
> > Can anyone put me on a track?
> >
> > Thank you
>
>
>
|
|
Posted by on May 10, 2007, 12:08 pm
If you were Registered and logged in, you could reply and use other advanced thread options Hello,
Sorry for the delay in getting back to you. I some how lost the
thread. Anyways, the code is below. Note that I used a custom function
to search for users and groups because the local computer (WinNT) does
not support Searcher and returns COM exceptions on Find. Also, this
was for my console test app. Replace the MessageBox responses as
appropriate for a web page.
Hope this helps,
J Wolfgang Goerlich
private CreateUser(string Username, string Fullname, string
Description, string Password, string ConfirmPassword)
{
// Confirm the password
if (Password != ConfirmPassword)
{
MessageBox.Show("The password was not correctly
confirmed. Please ensure that the password and confirmation match
exactly.");
return;
}
// Bind to the computer
DirectoryEntry Computer = new DirectoryEntry("WinNT://" +
Environment.MachineName + ",computer");
try
{
if (Computer.Name.ToLower() !=
Environment.MachineName.ToLower())
{
MessageBox.Show("Cannot connect to the computer at
this time.");
return;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
return;
}
// Check for duplicate accounts
if (DoesObjectExist(Computer, Username, "User") == true)
{
MessageBox.Show("The account already exists. Please
enter a different username.");
return;
}
// Create the user account
DirectoryEntry User = new DirectoryEntry();
User = Computer.Children.Add(Username, "user");
User.Properties["FullName"].Add(Fullname);
User.Properties["Description"].Add(Description);
User.Invoke("SetPassword", new object[] { Password });
User.CommitChanges();
// Add group memberships
Computer.RefreshCache();
if (DoesObjectExist(Computer, "Administrators", "Group")
== true)
{
DirectoryEntry Administrators =
Computer.Children.Find("Administrators", "group");
Administrators.Invoke("Add", new Object[]
{ User.Path.ToString() });
}
if (DoesObjectExist(Computer, "Users", "Group") == true)
{
DirectoryEntry Users = Computer.Children.Find("Users",
"group");
Users.Invoke("Add", new Object[]
{ User.Path.ToString() });
}
MessageBox.Show("Created " + Username + ".");
}
private bool DoesObjectExist(DirectoryEntry Computer, string
ObjectName, string ObjectClassName)
{
// This function addresses two concerns about
DirectoryServices on the local computer:
// Directory.Children.Find throws a COM exception if the
entry is not found.
// DirectorySearcher is not supported under WinNT.
// Valid values for ClassName (SchemaClassName) are:
// User, Group, Service
foreach (DirectoryEntry dc in Computer.Children)
{
if (dc.SchemaClassName.ToLower() ==
ObjectClassName.ToLower())
{
if (dc.Name.ToLower() == ObjectName.ToLower())
{
// Found a child object that matched the
object name and schema class
return true;
}
}
}
|
| Similar Threads | Posted | | Creating a very limited user account to run a service | September 6, 2006, 11:04 am |
| Local system and user account - registry | October 5, 2006, 6:27 am |
| Creating a recovery agent on local computer | January 12, 2006, 9:40 pm |
| Creating a Thread as a different user? | September 13, 2006, 1:44 pm |
| Renamed Local Administrator Account Name Reverts to Old Account Name | November 30, 2005, 4:39 am |
| User Profiles being automatically created for local user accounts | March 24, 2006, 9:45 am |
| Re: cracking local admin account | September 4, 2005, 11:56 am |
| RE: cracking local admin account | September 15, 2007, 10:36 pm |
| Local System Account & Network Access | June 29, 2006, 9:08 am |
| How does your organizations manage the local administrator account on workstations? | August 29, 2008, 11:32 pm |
|