472,119 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

Active Directory Adding user to Group, HRESULT: 0x80072014

I am not sure if this is the proper place to put this thread but I have run into a road block. I am writing a web app that will create groups in Active Directory then add users to those groups. I have it creating the groups just fine however when i go to add a user i get. The requested operation did not satisfy one or more constraints associated
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
  1. public string AddUser2Group(string groupName, string location, string userID)
  2.  
  3. {
  4. DirectoryEntry AD = new DirectoryEntry("LDAP://DC=ad,DC=domainname,DC=com);
  5. DirectorySearcher ADFind = new DirectorySearcher(AD);
  6. DirectoryEntry group = AD.Children.Find("OU=" + location + ", OU=SelfServeGroups");
  7.  
  8. // Add a single user to a group;
  9. ADFind.Filter = "(&(objectCategory=user)(cn=" + userID + "))";
  10. SearchResult results = ADFind.FindOne();
  11.  
  12. //To add the user's distinguished name to the member property on the group object, use the Add method.
  13. string DN = results.Properties["distinguishedName"][0].ToString();
  14. group.Properties["member"].Add( DN );
  15.  
  16. //Commit the changes to the directory.
  17. group.CommitChanges();
  18. return userID;
  19. }
When I run it in debug mode everything apears to be good DN is the full Distinguished name. Please help me


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
Feb 7 '07 #1
4 10571
kenobewan
4,871 Expert 4TB
I believe that you need to use the group.invoke method - see 8. Add a user to a group in this article:
Active Directory and .NET
Feb 8 '07 #2
Thank you.

Sorry I have figured out the problem. I was sleeping last night when for some odd reason I was thinking about this project and it came to me i never said what group to add the user to. I am trying to add it to the OU that the group is in and not the group. Sorry for all of you who took a look at this but I have solved it. I guess working on code for the day and just looking at this made me just over look this small point.
Feb 8 '07 #3
I believe that you need to use the group.invoke method - see 8. Add a user to a group in this article:
Active Directory and .NET

Thank you very much for that link that is a very good walkthrough.
Feb 8 '07 #4
kenobewan
4,871 Expert 4TB
Sleep and the art of problem solving, glad that you found the article interesting :).
Feb 9 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Leo_Surf | last post: by
3 posts views Thread by Luis Esteban Valencia | last post: by
4 posts views Thread by Marc | last post: by
1 post views Thread by tangus via DotNetMonster.com | last post: by
2 posts views Thread by Jim in Arizona | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.