Solved

User Cannot Change Password problem

Posted on 2009-04-07
4
381 Views
Last Modified: 2012-05-06
I have this c# code that works to check the "User Cannot Change Password" check box but how can I unckeck it.

Thanks
string PASSWORD_GUID = "{ab721a53-1e2f-11d0-9819-00aa0040529b}";
 
            string[] trustees = new string[] { @"NT AUTHORITY\SELF", "EVERYONE" };
 
            ActiveDs.IADsSecurityDescriptor sd = (ActiveDs.IADsSecurityDescriptor)user.Properties["ntSecurityDescriptor"].Value;
            ActiveDs.IADsAccessControlList acl = (ActiveDs.IADsAccessControlList)sd.DiscretionaryAcl;
            ActiveDs.IADsAccessControlEntry ace = new ActiveDs.AccessControlEntry();
            foreach (string trustee in trustees)
            {
                ace.Trustee = trustee;
                ace.AceFlags = 0;
                ace.AceType = (int)
                ActiveDs.ADS_ACETYPE_ENUM.ADS_ACETYPE_ACCESS_DENIED_OBJECT;
                ace.Flags = (int)ActiveDs.ADS_FLAGTYPE_ENUM.ADS_FLAG_OBJECT_TYPE_PRESENT;
                ace.ObjectType = PASSWORD_GUID;
                ace.AccessMask = (int)ActiveDs.ADS_RIGHTS_ENUM.ADS_RIGHT_DS_CONTROL_ACCESS;
                acl.AddAce(ace);
            }
            sd.DiscretionaryAcl = acl;
            user.Properties["ntSecurityDescriptor"].Value = sd;
            user.CommitChanges();

Open in new window

0
Comment
Question by:scanet
  • 3
4 Comments
 
LVL 18

Expert Comment

by:Americom
ID: 24094162
Usually check and uncheck is just a 1 instead of 0. Have you tried it yet?
0
 

Author Comment

by:scanet
ID: 24094871
Hi,

I think I tried that but I will give it another go this evening.

Thanks
0
 

Author Comment

by:scanet
ID: 24099240
I tried to change ace.AceFlags = 0; to 1 but it did not work. is there another metod I could use?

Thanks
0
 

Accepted Solution

by:
scanet earned 0 total points
ID: 24101047
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question