c# - 我收到异常“发生约束冲突。\r\n”
问题描述
从未使用过 Active Directory,需要帮助更新 Active Directory 中的用户记录。这是在 ASP.NET Web 应用程序中。
String objLdapConnection = ConfigurationManager.ConnectionStrings["ADConnection"].ToString();
DirectorySearcher objSearcher = new DirectorySearcher(objLdapConnection);
objSearcher.Filter = "(sAMAccountName=" + this.txtAccount.Text + ")";
SearchResult objResult = objSearcher.FindOne();
if (objResult != null)
{
DirectoryEntry objUpdateEntry = objResult.GetDirectoryEntry();
if (this.txtWorkPhone.Text != strWorkPhone)
objUpdateEntry.Properties["telephoneNumber"].Value = this.txtWorkPhone.Text;
if (this.txtExtension.Text != strExtension)
objUpdateEntry.Properties["ipPhone"].Value = this.txtExtension.Text;
if (this.ddlOffice.SelectedItem.Text != strOffice)
objUpdateEntry.Properties["l"].Value = this.ddlOffice.SelectedItem.Text;
if (this.ddlDepartment.SelectedItem.Text != strDepartment)
objUpdateEntry.Properties["department"].Value = this.ddlDepartment.SelectedItem.Text;
if (this.txtJobTitle.Text != strTitle)
objUpdateEntry.Properties["title"].Value = this.txtJobTitle.Text;
if (this.txtSupervison.Text != strSuperVisor)
objUpdateEntry.Properties["manager"].Value = this.txtSupervison.Text;
objUpdateEntry.CommitChanges();
}
else
{
this.lblresult.Text = "Account was not found";
}
解决方案
推荐阅读
- python - 在 Matplotlib 线图上的标准差之间填充
- reactjs - React 将 API 数据传递给图表
- c# - 如何选择不在groupby中的属性
- python - 缺少usecols时如何迭代另一个xlsx
- string - ValueError:格式错误的节点或字符串:<_ast.Name object at 0x0000016835AEE3D0>
- linux - 导致 git 子模块失败的环境变量
- swift - 声明一个指向属性的指针并将其作为 inout 参数传递给 Swift 中的 func?
- c# - 稀疏矩阵(下一个元素)
- c++ - 使用位操作填充一个 int 集
- sql - 如何通过 SQL 查询从最早/最新行开始区分列?