在 Microsoft Active Directory(AD) 中,如果有人密码过期,如何更改密码使用他们的旧密码。
我知道 System.DirectoryService
有一个 ChangePassword
方法,但是当密码过期时它不起作用。
我比你更需要一些帮助!
顺便说一句,不能使用SetPassword
方法,因为它必须有特殊权限。
最佳答案
您可以使用 NetUserChangePassword 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
);
关于c# - 密码过期时如何在事件目录中更改密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25281400/