Here is one method that you could use to accomplish this:
You can invoke a DOS batch script which will add the user to the group. The
DOS command would be as follows:
net localgroup administrators DOMAIN\username /add
Then, generate a text file containing the above commands/usernames and save
the file as adduser.bat.
Then, add the following code to whatever event you wanted to use to add the
user:
System.Diagnost ics.Process proc = new System.Diagnost ics.Process();
proc.EnableRais ingEvents=false ;
proc.StartInfo. FileName="c:\\f oldername\\addu ser.bat";
proc.Start();
If you also need to create the user, you can add that command to your batch
file using the proper syntax for the addusers utility.
Chris
--------------------
Content-Class: urn:content-classes:message
From: "Ching-Lung" <cl******@hotma il.com>
Sender: "Ching-Lung" <cl******@hotma il.com>
Subject: Adding new user to admin group
Date: Wed, 7 Jan 2004 12:21:13 -0800
Lines: 7
Message-ID: <02************ *************** *@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Thread-Index: AcPVW8u58oboNYH 9Rj2maM6colIwCQ ==
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
Path: cpmsftngxa07.ph x.gbl
Xref: cpmsftngxa07.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:2003 99
NNTP-Posting-Host: tk2msftngxa12.p hx.gbl 10.40.1.164
X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
Hi,
Is there any way to add new user to local admin group in
C# ASP.NET?
Thanks,
-CL