我需要查找一个Web应用程序的示例,最好是ASP.NET,但任何其他Web语言都可以,它可以让Mac和Windows用户更改其AD密码。
任何技术,应用程序或源代码都会很棒。
P.S:我们的Mac没有与AD连接,我们也有Windows用户。
谢谢!
答案 0 :(得分:1)
要查看的相关库是 System.DirectoryServices 。你的网络应用程序中的这样的东西将起到作用:
// Elsewhere in your code:
using System.DirectoryServices;
// ...
string u = "userToFind"; // User to look for goes here.
DirectoryEntry de = GetDirectoryObject();
DirectorySearcher s = new DirectorySearcher();
s.SearchRoot = de;
s.Filter = "(&(objectClass=user)(SAMAccountName=" + u + "))";
s.SearchScope = SearchScope.Subtree;
SearchResult r = s.FindOne();
// Connect with user's credentials.
de = (r != null) ? new DirectoryEntry(
r.Path, "user", "pwd", AuthenticationTypes.Secure) : null;
// ...
try {
// Change the password.
de.Invoke("ChangePassword", new object[]{strOldPassword, strNewPassword});
}
catch (Exception ex) {
Debug.WriteLine("Error changing password. Reason: " + ex.Message);
}