Comexception when setting domain password with directoryentry in a ASP.NET project

  • Thread starter Thread starter Marek Kopanski
  • Start date Start date
M

Marek Kopanski

Hallo,

I have to change a user password in my ASP.NET project.
In the first step I was trying to change my own passwort (as example) in
Active Directory on my Server, but already at this point I get problems.
Can somebody help me?

1. I use following fragment of code:
-----------------------------------
DirectoryEntry DirEntry;

DirEntry = new DirectoryEntry(@"WinNT://XXX-DOMAIN","MyName","MyPassword");

DirEntry.Invoke("setPassword", "testtest");

@"WinNT://XXX-DOMAIN"," is the name of the Server

2. Error
--------------------------------

The line:

DirEntry.Invoke("setPassword", "testtest");

fires an error:

System.Runtime.InteropServices.COMException: unknown name.

Can somebody tell me, what I am doing wrong?

Greetings

Marek
 
Hi Marek,

you are probably getting this error because by default ASP.NET account runs
with minimum privileges and hence it doesn't have access to such functions in
the AD. Either use impersonation or pass on the credentials of an user who
has the rights to change user passwords and it should work.

HTH.

Kaustav Neogy.
 
Back
Top