I am trying to update a user's ad properties but I am getting error:
the server is unwilling to process the request active directory on commit chnages function();
Please see code below:
using
System;using
System.Data;using
System.Configuration;using
System.Web.Security;using
System.Web.UI;using
System.Web.UI.WebControls;using
System.Web.UI.WebControls.WebParts;using
System.Web.UI.HtmlControls;using
System.DirectoryServices;using
System.DirectoryServices.ActiveDirectory;using
System.DirectoryServices.Protocols;using
System.DirectoryServices.AccountManagement;using
System.Collections;using
System.ComponentModel;using
System.IO;using
System.Xml;using
System.Xml.XPath;using
System.Diagnostics.CodeAnalysis;public
partial class _Default : System.Web.UI.Page{
{
TxtUserId.Focus();
}
{
de.Path =
protected void Page_Load(object sender, EventArgs e)public static DirectoryEntry GetDirectoryEntry()DirectoryEntry de = new DirectoryEntry();"LDAP://vaa.vtg.local"; /*modified*/de.Username =
"install";/*modified*/de.Password =
"C0pyright";/*modified*/de.AuthenticationType =
}
{
AuthenticationTypes.Secure;return de;protected void CmdSearch_Click(object sender, EventArgs e)// System.Diagnostics.Debugger.Break();
username = TxtUserId.Text;
deSearch.SearchRoot = de;
deSearch.Filter =
{
Response.Write(
TxtUserId.Text =
}
String username;DirectoryEntry de = GetDirectoryEntry();DirectorySearcher deSearch = new DirectorySearcher();"(&(objectClass=user) (SAMAccountName=" + username + "))";SearchResultCollection results = deSearch.FindAll();if (results.Count == 0)"<script language='javascript'> { alert('This User ID Does not Exist, please type right ID'); }</script>");" ";/* global::System.Windows.Forms.MessageBox.Show("This User ID Does not Exist,please type right ID");*/
else{
DirectoryEntry entry = GetDirectoryEntry();String account = username.Replace(@"vaa\", "");try{
search.Filter =
search.PropertiesToLoad.Add(
search.PropertiesToLoad.Add(
search.PropertiesToLoad.Add(
search.PropertiesToLoad.Add(
search.PropertiesToLoad.Add(
search.PropertiesToLoad.Add(
search.PropertiesToLoad.Add(
search.PropertiesToLoad.Add(
search.PropertiesToLoad.Add(
search.PropertiesToLoad.Add(
search.PropertiesToLoad.Add(
search.PropertiesToLoad.Add(
{
LblDispName.Text = result.Properties[
LblDept.Text = result.Properties[
LblJob.Text = result.Properties[
LblEmpType.Text = result.Properties[
LblBV.Text = result.Properties[
manager = managerModified[0].Substring(3);
LblMngr.Text = manager;
LblCO.Text = result.Properties[
LblCountry.Text = result.Properties[
LblTelephone.Text = result.Properties[
Lblmail.Text = result.Properties[
LblDN.Text = result.Properties[
{
memberof = memberofModified[0].Substring(3);
ListMemberOf.Items.Add(memberof);
}
}
}
{
}
}
}
{
DirectorySearcher search = new DirectorySearcher(entry);"(SAMAccountName=" + account + ")";"displayName");"department");"title");"employeeType");"vaaBusinessVertical");"manager");"company");"co");"telephoneNumber");"mail");"distinguishedName");"memberOf");SearchResult result = search.FindOne();if (result != null)"displayname"][0].ToString();"department"][0].ToString();"title"][0].ToString();"employeeType"][0].ToString();"vaaBusinessVertical"][0].ToString();String manager = result.Properties["manager"].ToString();string[] managerModified = manager.Split(',');"company"][0].ToString();"co"][0].ToString();"telephoneNumber"].ToString();"mail"][0].ToString();"distinguishedName"][0].ToString();for (int groupCount = 0; groupCount < result.Properties["memberOf"].Count; groupCount++)String memberof = result.Properties["memberOf"][groupCount].ToString();string[] memberofModified = memberof.Split(',');catch (Exception ex)string debug = ex.Message;protected void CmdAssign_Click(object sender, EventArgs e)// System.Diagnostics.CodeAnalysis();
// System.Diagnostics.Debug;
// System.Diagnostics.DebuggableAttribute();
username = TxtUserId.Text;
deSearch.SearchRoot = de;
deSearch.Filter =
String username;String userdn;DirectoryEntry de = GetDirectoryEntry();DirectorySearcher deSearch = new DirectorySearcher();"(&(objectClass=user) (SAMAccountName=" + username + "))";SearchResultCollection results = deSearch.FindAll();DirectoryEntry entry = GetDirectoryEntry();String account = username.Replace(@"vaa\", "");try{
search.Filter =
search.PropertiesToLoad.Add(
search.PropertiesToLoad.Add(
userdn = result.Properties[
Response.Write(userdn);
{
entry =
ListBox1.SelectedIndex = 0;
DirectorySearcher search = new DirectorySearcher(entry);"(SAMAccountName=" + account + ")";"distinguishedName");"memberOf");SearchResult result = search.FindOne();"distinguishedName"][0].ToString();if (DDListDeptTemp.SelectedItem.ToString() == "SSS")new DirectoryEntry("LDAP://vaa.vtg.local", "aryam", "Pucchu9nonu", AuthenticationTypes.Secure);string groups = ListBox1.SelectedItem.Text;/*Listbox1.setselected(0,True);*/
/*entry.Properties["memberOf"].Add(groups);*/entry.Properties[
Response.Write(disp);
"displayname"].Value = "XYZ";string disp = entry.Properties["displayname"][0].ToString();/*Response.Write("<script language='javascript'> { window.close();}</script>");*/entry.CommitChanges();
Response.Write(disp);
entry.Close();
}
{
entry =
xmlDocument.Load(
else if (DDListDeptTemp.SelectedValue == "Administration LHR (3010) - Template1")new DirectoryEntry("LDAP://vaa.vtg.local", "install", "C0pyright", AuthenticationTypes.Secure);XmlDocument xmlDocument = new XmlDocument();"XMLFile2.xml");XmlNodeList xmldept = xmlDocument.GetElementsByTagName("Group1");string x;try{
//Search user name in AD Group
//string pathADGroup = "LDAP://vaa.vtg.local/CN=GS_CTX_BO_GTI,OU=Groups,OU=United Kingdom,DC=vaa,DC=vtg,DC=local";
objEntry.Path =
objEntry.Username=
objEntry.Password =
objEntry.AuthenticationType=
DirectoryEntry objEntry = new DirectoryEntry();"LDAP://vaa.vtg.local/CN=GS_CTX_BO_GTI,OU=Groups,OU=United Kingdom,DC=vaa,DC=vtg,DC=local";@"vaa\install";"C0pyright";AuthenticationTypes.Secure;// objEntry.Properties["member"].Add("testid");
// DirectoryEntries users = objEntry.Children;
// DirectoryEntry user = users.Add("CN=Megha Arya", "user");
// user.Properties["company"].Add("Some Company");
objEntry.Properties[
"member"].Value = "GS_CTX_BO_GTI";// objEntry.Properties["member"][0].Equals(objEntry.Path);
// string d1= objEntry.Properties["title"][0].ToString();
try{
objEntry.CommitChanges();
}
{
}
catch (Exception ex1)string debug1 = ex1.Message;// string obj = objEntry.Children.Find("member").ToString();
// Response.Write(obj);objEntry.Close();
}
{
}
catch (Exception ex)string debug = ex.Message;//DirectoryEntry dirEntry = new DirectoryEntry("LDAP://vaa.vtg.local");
//DirectorySearcher search = new DirectorySearcher(dirEntry);
//search.Filter = "(SAMAccountName= GS_CTX_BO_GTI)";
//search.PropertiesToLoad.Add("distinguishedName");
//dirEntry.Properties["member"].Add("testid");
//dirEntry.CommitChanges();
//dirEntry.Close();
// DDListDeptTemp.Items.Add("-----------Select-----------");
// foreach (XmlNode node in xmldept)
// {
// x = node.Attributes.GetNamedItem("text").Value;
//// group.Invoke("Add", new object[] { deUser.Path.ToString() });
// entry.Properties["telephoneNumber"].Add("00001");
// //entry = de.Children.Add("DN=",x);
// // String memberof = result.Properties["memberOf"][groupCount].ToString();
// // string[] memberofModified = memberof.Split(',');
// // memberof = memberofModified[0].Substring(3);
// // ListMemberOf.Items.Add(memberof);
// try
// {
// entry.CommitChanges();
// }
// catch (Exception ex1)
// {
// string desdsd = ex1.Message;
// }
// Response.Write("delts");
// }
//}
{
entry = new DirectoryEntry("LDAP://" + groupdn2);
entry.Properties["member"].Add(userdn);
entry.CommitChanges();
entry.Close();
} */
/*if (Dept == "IOCC")}
}
{
}
}
{
Response.Write(
}
{
TxtUserId.Text =
LblDispName.Text =
LblDept.Text =
LblJob.Text =
LblEmpType.Text =
LblBV.Text =
LblMngr.Text =
LblCO.Text =
LblCountry.Text =
LblTelephone.Text =
Lblmail.Text =
LblDN.Text =
catch (Exception ex)string debug = ex.Message;protected void CmdExit_Click(object sender, EventArgs e)"<script language='javascript'> { window.close();}</script>");protected void CmdReset_Click(object sender, EventArgs e)"";"";"";"";"";"";"";"";"";"";"";"";//LblGM.Text = "";ListMemberOf.Items.Clear();
}
{
{
DDListDept.Items.Clear();
DDListDept.Items.Add(
DDListDept.Items.Add(
DDListDept.Items.Add(
DDListDept.Items.Add(
}
protected void DDListBV_SelectedIndexChanged(object sender, EventArgs e)if (DDListBV.SelectedValue == "Airports, Cargo and Overseas")"-------------Select--------------- ");"Airports");"Cargo");"Overseas");else
{
DDListDept.Items.Clear();
DDListDept.Items.Add(
}
}
{
{
xmlDocument.Load(
DDListDeptTemp.Items.Add(
{
x = node.Attributes.GetNamedItem(
DDListDeptTemp.Items.Add(x);
}
}
{
DDListDeptTemp.Items.Clear();
DDListDeptTemp.Items.Add(
DDListDeptTemp.Items.Add(
}
}
{
}
{
{
xmlDocument.Load(
DDListDeptTemp.Items.Add(
{
x = node.Attributes.GetNamedItem(
ListBox1.Items.Add(x);
if (DDListBV.SelectedValue == "Back Office")"BB");protected void DDListDept_SelectedIndexChanged(object sender, EventArgs e)if (DDListDept.SelectedValue == "Airports")XmlDocument xmlDocument = new XmlDocument();"XMLFile2.xml");XmlNodeList xmldept = xmlDocument.GetElementsByTagName("Department");string x;"-----------Select-----------");foreach (XmlNode node in xmldept)"text").Value;else if (DDListDept.SelectedValue == "Cargo")" ");"DDD");protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)protected void DDListDeptTemp_SelectedIndexChanged(object sender, EventArgs e)if (DDListDeptTemp.SelectedValue == "Administration LHR (3010) - Template1")XmlDocument xmlDocument = new XmlDocument();"XMLFile2.xml");XmlNodeList xmldept = xmlDocument.GetElementsByTagName("Group1");string x;"-----------Select-----------");foreach (XmlNode node in xmldept)"text").Value;// Response.Write(x);}
}
}
{
}
{
}
}
protected void XmlDataSource1_Transforming(object sender, EventArgs e)protected void ListMemberOf_SelectedIndexChanged(object sender, EventArgs e)
PLease help