Runtime COMException when adding directory objects

dl
Date: 06/09/05


Date: Thu, 9 Jun 2005 17:50:58 +0800

Hi
I have written a code-behind page with exact lines of code and it works.
            string dirPath = "LDAP://ou=" + _ouName + "," + _domain;
            DirectoryEntry entry = new DirectoryEntry(dirPath);
                string cn = fname + " " + mi + " " + lname;
                DirectoryEntry newUser = entry.Children.Add(cn, "user");
                string sAMName = getsAMAcName(fname, lname, mi);
                newUser.Properties["sAMAccountName"].Add(sAMName);
                newUser.CommitChanges();

But when I move these lines to a class method which is then called by the
code-behind page I got errors on "CommitChanges".

Any idea, please?!
TIA

[COMException (0x80072035): The server is unwilling to process the request.]
   System.DirectoryServices.Interop.IAds.SetInfo() +0
   System.DirectoryServices.DirectoryEntry.CommitChanges() +37
   NETDS.DirEntry.entryAdd(String fname, String lname, String mi, String
telno, Int32 flag) +307
   NETDS.EntryCreate.btnEntryCreate_Click(Object sender, EventArgs e) +545
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String eventArgument) +57
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain() +1281

----------------------------------------------------------------------------

----
-- 

Quantcast