473,835 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Active Directory Adding user to Group, HRESULT: 0x80072014

9 New Member
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.Director yServices.Direc toryServicesCOM Exception: 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.Propertie s["member"].AddRange(new string[] { DN });
Line 120: //Commit the changes to the directory.
Line 121: group.CommitCha nges();
Line 122: return userID;
Line 123: }


Source File: c:\Inetpub\wwwr oot\ADGU\App_Co de\ActiveDirect ory.cs Line: 121

Stack Trace:

[DirectoryServic esCOMException (0x80072014): The requested operation did not satisfy one or more constraints
associated with the class of the object. (Exception from HRESULT: 0x80072014)]
System.Director yServices.Direc toryEntry.Commi tChanges() +171
ActiveDirectory .AddUser2Group( String groupName, String location, String userID) in c:\Inetpub\wwwr oot\ADGU\App_Co de\ActiveDirect ory.cs:121
Test.Button3_Cl ick(Object sender, EventArgs e) in c:\Inetpub\wwwr oot\ADGU\Test.a spx.cs:43
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +105
System.Web.UI.W ebControls.Butt on.RaisePostBac kEvent(String eventArgument) +107
System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring eventArgument) +7
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler sourceControl, String eventArgument) +11
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
System.Web.UI.P age.ProcessRequ estMain(Boolean includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +5102






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

Version Information: Microsoft .NET Framework Version:2.0.507 27.42; ASP.NET Version:2.0.507 27.42
Feb 7 '07 #1
4 10932
kenobewan
4,871 Recognized Expert Specialist
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
cpajoe2001
9 New Member
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
cpajoe2001
9 New Member
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 Recognized Expert Specialist
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
5457
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 machine then it works again. here is one of the method where am calling the AD public bool UserExist(string UserName) {
6
2417
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 Idea about ASP.net Please Help Thanks in Advance.
3
3495
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 info
4
2111
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 code does not work: DirectoryEntry ou = new DirectoryEntry("LDAP://ou=WISDM,dc=WISDM,dc=wisdm,dc=org", "username", "password"); // Use the Add method to add a user in an organizational unit. DirectoryEntry usr = ou.Children.Add("CN=" +...
1
3899
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 = New DirectoryEntry("LDAP://domain") Dim mySearcher As New DirectorySearcher(enTry) Dim resEnt As SearchResult mySearcher.Filter = ("(objectClass=*)") mySearcher.SearchScope = SearchScope.Subtree
0
2747
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 ------------------------------------------------- To map a certificate to a user account Open Active Directory Users and Computers.
2
4700
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 because all we do is verify the user on the login form so we can redirect them to the appropriate page based on their group. The code to authenticate is: Public Function IsAuthenticated(ByVal domain As String, ByVal username As String, ByVal...
2
5994
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 use the System.DirectoryServices.ActiveDirectory namespace. I don't even know if this is the right way to go as I can't seem to find anything in that namespace that would help me query active directory for names. I can't use an LDAP query...
2
2693
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 to update the managers name. I got a datareader that returns all the employees from the database then a method checks each one of the records and compares them in AD and them commits the changes to the users information. This is what I have try...
0
9810
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10815
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10562
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10236
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9348
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5639
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5805
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3997
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3092
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.