【发布时间】:2014-01-02 11:25:48
【问题描述】:
我正在尝试使用以下代码更新 Active Directory 中用户的电子邮件地址。它执行成功,但 Active Directory 中的电子邮件地址没有改变。
我该如何解决?
try
{
using (var context = new PrincipalContext(ContextType.Domain, "yurs.yucc"))
{
if (context.ValidateCredentials(username, password))
{
UserPrincipal usrPrincipal = new UserPrincipal(context);
usrPrincipal.EmailAddress = "raedsaleh11@gmail.com";
}
}
}
catch (Exception ex)
{
// TODO: log exception
}
【问题讨论】:
-
虽然不是您问题的答案,但您不应使用空的 catch 块,异常将被抑制。使用它不是一个好习惯。
标签: asp.net c#-4.0 active-directory