ASP.NET Adding a User to Active Directory

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi All,

I have an asp.net app, which is supposed to add a user to the AD Users group.
I am using the ASP Memberhsip provider for this and have configured it in the web.config file. All works Well, I can login, list users, etc etc.

However when it comes to creating a user, I get the following error:

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.


In my webconfig I have set the following:

<identity impersonate="true" userName="domain\Administrator" password="SomePass"/> (I know this isnt secure, but it is a test enviroment setup especially for my learning.

So I am lost to why I cant create a new user in the AD Domain.

Does anyone have any ideas? The code I am using is:

string username = "SwedishChef";
string password = "bj#kbj$k";


Membership.CreateUser(
username, password);



And here is my Provider setup from my web.config:

<membership defaultProvider="MyADMembershipProvider">
<providers>
<remove name="AspNetSqlMembershipProvider" />
<add
name="MyAdMembershipProvider"

type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="ADConn"
connectionUsername="domain\Administrator"
connectionPassword="SomePass"
applicationName="/ControlPanel"
enableSearchMethods="true"
/>
</providers>

</membership>


.



Relevant Pages

  • Re: ASP.NET Adding a User to Active Directory [FIXED]
    ... I am using the ASP Memberhsip provider for this and have configured it in the web.config file. ... An unhandled exception occurred during the execution of the current web request. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: [Full-Disclosure] Teen hacker controls ebay
    ... Some of us call it daily business. ... if you happen to _move_ a domain from one provider to ... If your ISP does not answer ... the request, the KK will be ACKed, which is a good thing. ...
    (Full-Disclosure)
  • Re: "is now available for editing" problem with Excel-automated mail merge
    ... only have one provider per Access record. ... Each request record has the ... So we import the data into Excel, manipulate it with VBA to produce ... one row per user with all requested brokers (broker1, broker2, ...
    (microsoft.public.excel)
  • Re: REGDB_E_CLASSNOTREG(0x80040154)
    ... > provider is not registered on the local machine.] ... > Exception Details: System.Data.OleDb.OleDbException: No error ... > [InvalidOperationException: The 'Micosoft.Jet.OLEDB.4.0' provider is ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Custom Membership Provider
    ... I have written a custom membership provider based to access an ... shared hosting environment I get a security exception of the type IO ... This boils down to a number of lines of code in my provider ... machineKey = ...
    (microsoft.public.dotnet.framework.aspnet.security)