473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 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 10837
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: huzz | last post by:
I have web application that quaries the Active Directory to get user details.. everything works fine but someday I'll get System.Runtime.InteropServices.COMExection and if I restart the client...
6
by: Leo_Surf | last post by:
Hello, I need your help adding user in Active Directory from ASP.net website. Could any one provide me the complete code for the html page. As this is my curriculam project and I dont have any...
3
by: Luis Esteban Valencia | last post by:
Hello gusys, Is it possible to make my asp.net application add users to the AD , I also want to be able to delete users, modify their information, everything through a website. Thanks for the...
4
by: Marc | last post by:
So I am having some issues with code written by another developer that interfaces with Active Directory. We had a catastrophic failure on the server and had to recreate the AD. No the following...
1
by: tangus via DotNetMonster.com | last post by:
Hello all, I'm really struggling with getting some Active Directory code to work in ASP.NET. Can you please provide assistance? I am executing the following code: Dim enTry As DirectoryEntry =...
0
by: jakobsgaard | last post by:
It is possible to Map a certificate to a Active Directory User Account from DotNet? Please provide an example. Best regards, Ejnar Jakobsgaard...
2
by: P Webster | last post by:
We recently moved a web site that validated user credentials in Active Directory from IIS 5.1 to IIS 6, and the validation code no longer works. The web.config file is set to Windows authentication...
2
by: Jim in Arizona | last post by:
My goal, somehow, is to populate a dropdownlist with all the user names in active directory. I don't even know where to begin, really. I added a reference to System.DirectoryServices so I could...
2
by: lairpr74 | last post by:
I am trying to update the managers name in active directory with an application I got that updates active directory. I been strugling with this for a few weeks now and couldn't find the best way...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.