IIS中有一个组件IISADMPWD可以更改Active Directory的密码。
操作步骤:一、新建一个虚拟目录,路径指向C:\WINDOWS\system32\inetsrv\iisadmpwd;
             二、设置为https,可以执行script,还要指定domain名称;
             三、web扩展中将Active Server Pages启动。

自己建能更改AD密码的网站,其所在服务器必须在AD域中。
 1DirectoryEntry ent = new DirectoryEntry("LDAP://" + Session["Ldappath"].ToString(), 
 2
 3Components.DAL.myData.DecryptDES(Session["ADUserName"].ToString(), "key"),
 4                     txtCurPwd.Text.Trim(),AuthenticationTypes.Secure);
 5   DirectorySearcher DSr = new DirectorySearcher(ent);
 6 DSr.SearchScope = SearchScope.Subtree;
 7 DSr.Filter = "(sAMAccountName=" +
           Components.DAL.myData.DecryptDES(Session[
"ADUserName"].ToString(), "key"+ ")";
 8 SearchResult sr = DSr.FindOne();
 9  DirectoryEntry entry = sr.GetDirectoryEntry();10        
14  ActiveDs.IADsUser user = (ActiveDs.IADsUser)entry.NativeObject;
15  user.ChangePassword(txtCurPwd.Text.Trim(), txtNewPwd.Text.Trim());
16            Response.Write("<script language=javascript>alert('Change password successed!');</script>");

posted on 2008-07-04 15:45  Milo Liu  阅读(806)  评论(0)    收藏  举报