Reputation: 23
In Microsoft Active Directory(AD), if someone password expired, how to change password using their old password.
I know System.DirectoryService
has one ChangePassword
Method, but it not working when the password expired.
I want some help, than you very much!
BTW, cannot use SetPassword
Method, because it have to has special privileges.
Upvotes: 2
Views: 1044
Reputation: 4678
You can use the NetUserChangePassword function in netapi32.dll.
[DllImport("netapi32.dll", CharSet=CharSet.Unicode,
CallingConvention=CallingConvention.StdCall,
SetLastError=true )]
static extern uint NetUserChangePassword (
[MarshalAs(UnmanagedType.LPWStr)] string domainname,
[MarshalAs(UnmanagedType.LPWStr)] string username,
[MarshalAs(UnmanagedType.LPWStr)] string oldpassword,
[MarshalAs(UnmanagedType.LPWStr)] string newpassword
);
Upvotes: 1