Change current users password?

  • Thread starter Thread starter news.microsoft.com
  • Start date Start date
N

news.microsoft.com

I am looking for a way to allow the currently logged in user to change
his/her password. Is there an API I can interop to in c#?

Tia!
 
Ram said:
You want to change it's password where - on WinNT? ActiveDirectory?

--Ram



Both. I figgured out the code last night. Hopefully this will help someone
else!


// Allows password change for domain or local system
[DllImport("netapi32.dll", CharSet=CharSet.Auto)]
private extern static int NetUserChangePassword(
[MarshalAs(UnmanagedType.LPWStr)] string domainName, // set to null for
local machine/domain
[MarshalAs(UnmanagedType.LPWStr)] string userName, // set to null for
local user
[MarshalAs(UnmanagedType.LPWStr)] string oldPass,
[MarshalAs(UnmanagedType.LPWStr)] string newPass);
 
Back
Top