首页 > 解决方案 > 我收到异常“发生约束冲突。\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";
            }

标签: c#asp.netactive-directory

解决方案


推荐阅读