c# - 如何使用 C# 在 Exchange 中重置密码
问题描述
我无法从 C# 重置活动目录密码,我有这个代码
DirectoryEntry de = new DirectoryEntry(path, dominio + @"\" + usu, pass1, AuthenticationTypes.Secure);
DirectorySearcher ds = new DirectorySearcher(de);
try
{
string strFilter = "(&(objectClass=user)(|(sAMAccountName="+nameid+")))";
ds.Filter = strFilter;
ds.PropertiesToLoad.Add("displayName");
ds.PropertiesToLoad.Add("sAMAccountName");
ds.PropertiesToLoad.Add("DistinguishedName");
ds.PropertiesToLoad.Add("CN");
SearchResult result = ds.FindOne();
string dn = result.Properties["DistinguishedName"][0].ToString();
var user = result.GetDirectoryEntry();
user.Invoke("ChangePassword", new object[] { oldpassword, newpassword });
user.CommitChanges();
MessageBox.Show("ok");
}
catch(Exception ex)
{
MessageBox.Show("error");
}
它工作正常,直到 INVOKE 行,那是我收到错误的时候
user.Invoke("ChangePassword", new object[] { oldpassword, newpassword });
解决方案
推荐阅读
- laravel - 防止不存在的数据插入 - Laravel
- selenium - Selenium Java 基于嵌套元素文本选择 div
- php - 如何将二叉树存储为一维数组?
- javascript - onprogress 事件在 xmlHttpRequest Mozilla firefox 上不起作用
- android-fragments - 片段到片段共享元素无法使用 androidx.fragment.app.Fragment
- javascript - (Stripe API) 可以获取bank_account token,但不能获取card token
- php - POS 默认字体打印
- mysql - 如何在 laravel 中使用 FIND_IN_SET 获取最后更新的记录?
- functional-programming - 使用 lodash(或 ramda)拆分/嵌套 _.flow
- java - 如何将平面 JSON 转换为分层 java 类?