bind to object using adsi and asp.net/vb.net errors?

bind to object using adsi and asp.net/vb.net errors?

Post by Tulio Quinone » Wed, 29 May 2002 07:25:45



Hi,

I am trying to bing to an object via asp.net/vb.net in order to change the
objects password.  I would like to connect to the object using the objects
username and password.

I am using the following code however I am receiving errors:

Public Sub SubmitBtn_Click(ByVal Sender As Object, ByVal E As EventArgs)
Dim user As DirectoryEntry
user = New DirectoryEntry("WinNT://" + domain.Text & "/" + Account.Text &
",User", Account.Text, oldpassword.Text, AuthenticationTypes.Secure)
user.Invoke("SetPassword", New Object() {password.Text})
user.CommitChanges()
End Sub

Error Recieved is:

General access denied error
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: General access denied
error

The ASP.NET process is not authorized to access the requested resource. For
security reasons the default ASP.NET process identity is
'{machinename}\ASPNET', which has limited privileges. Consider granting
access rights to the resource to the ASP.NET process identity.

To grant ASP.NET write access to a file, right-click the file in Explorer,
choose "Properties" and select the Security tab. Click "Add" to add the
"{machinename}\ASPNET" user. Highlight the ASP.NET account, and check the
Write box in the Allow column.

Source Error:

Line 44:         Dim user As DirectoryEntry
Line 45:         user = New DirectoryEntry("WinNT://" + domain.Text & "/" +
Account.Text & ",User", Account.Text, oldpassword.Text,
AuthenticationTypes.Secure)
Line 46:         user.Invoke("SetPassword", New Object() {password.Text})
Line 47:         user.CommitChanges()
Line 48:

Source File: c:\inetpub\wwwroot\passwordchange\changepassword.aspx.vb
Line: 46

Stack Trace:

[UnauthorizedAccessException: General access denied error
]

[TargetInvocationException: Exception has been thrown by the target of an in
vocation.]
   System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr,
Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture,
String[] namedParameters) +0
   System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParameters) +473
   System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder
binder, Object target, Object[] args) +29
   System.DirectoryServices.DirectoryEntry.Invoke(String methodName,
Object[] args)
   passwordchange.changepassword.SubmitBtn_Click(Object Sender, EventArgs E)
in c:\inetpub\wwwroot\passwordchange\changepassword.aspx.vb:46
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   System.Web.UI.Page.ProcessRequestMain() +1263