NetUserAdd +aspx

  • Thread starter Thread starter Kjartan
  • Start date Start date
K

Kjartan

Hi.

I created a program which creates a user on my machine using
NetApi32.dll or more specifically NetUserAdd. The program runs fine
and a user is created on my machine (I used C#). Now I want to create
a user on my machine using aspx. Is this possible? I used the same
code I used in my C# program but I'm never able to create a user, is
this a permissions problem or something else??

I would much appreciate any help given.

Best regards,
Kjartan.
 
Kjartan said:
I created a program which creates a user on my machine using
NetApi32.dll or more specifically NetUserAdd. The program runs fine
and a user is created on my machine (I used C#). Now I want to create
a user on my machine using aspx. Is this possible? I used the same
code I used in my C# program but I'm never able to create a user, is
this a permissions problem or something else??

Hello Kjartan,

It is possible. Some months ago I wrote an application in ASP.NET
that contained administration pages that, amongst other things,
added users to local groups on the webserver machine.
I used ADSI to do this, but I guess using NetApi32
to add local users should work as well.

The important thing to ensure is that your code runs as a user
who is permitted to do this operation on the web server machine.
I think by default it runs as ASPNET, so probably you'll have
to change some settings. I'll describe the way I did this,
but keep in mind that I used Windows integrated security everywhere
and that will only work on intranet/extranet, don't know how to
achieve this with f.i. forms authentication.

1. In IIS, you need to disable anonymous access to the
folder/page and enable Windows integrated security.
This only works with intranet.

2. For ASP.NET, you need to enable impersonation in web.config.

Then the code on the web server should run with
the privileges of the user behind the web browser.

Best regards,

Eric Veltman
 
Thanks a lot for your swift reply. I tried your advice and everything
is working great.

Best Wishes,

Kjartan.
 
Back
Top