with the class of the object. (Exception from HRESULT: 0x80072014) And I can not find any help on this error. i'll post the stack trace below. Here is my code I am hoping someone can find out why it is failing.
Expand|Select|Wrap|Line Numbers
- public string AddUser2Group(string groupName, string location, string userID)
- {
- DirectoryEntry AD = new DirectoryEntry("LDAP://DC=ad,DC=domainname,DC=com);
- DirectorySearcher ADFind = new DirectorySearcher(AD);
- DirectoryEntry group = AD.Children.Find("OU=" + location + ", OU=SelfServeGroups");
- // Add a single user to a group;
- ADFind.Filter = "(&(objectCategory=user)(cn=" + userID + "))";
- SearchResult results = ADFind.FindOne();
- //To add the user's distinguished name to the member property on the group object, use the Add method.
- string DN = results.Properties["distinguishedName"][0].ToString();
- group.Properties["member"].Add( DN );
- //Commit the changes to the directory.
- group.CommitChanges();
- return userID;
- }
Server Error in '/ADGU' Application.
--------------------------------------------------------------------------------
The requested operation did not satisfy one or more constraints associated with the class of the object. (Exception from HRESULT: 0x80072014)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.DirectoryServices.DirectoryServicesCOMExcep tion: The requested operation did not satisfy one or more constraints associated with the class of the object. (Exception from HRESULT: 0x80072014)
Source Error:
Line 119: group.Properties["member"].AddRange(new string[] { DN });
Line 120: //Commit the changes to the directory.
Line 121: group.CommitChanges();
Line 122: return userID;
Line 123: }
Source File: c:\Inetpub\wwwroot\ADGU\App_Code\ActiveDirectory.c s Line: 121
Stack Trace:
[DirectoryServicesCOMException (0x80072014): The requested operation did not satisfy one or more constraints
associated with the class of the object. (Exception from HRESULT: 0x80072014)]
System.DirectoryServices.DirectoryEntry.CommitChan ges() +171
ActiveDirectory.AddUser2Group(String groupName, String location, String userID) in c:\Inetpub\wwwroot\ADGU\App_Code\ActiveDirectory.c s:121
Test.Button3_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\ADGU\Test.aspx.cs:43
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42