Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Modifying Active Directory ntSecurityDescriptor property in python-ldap

Posted on 2014-04-26
5
Medium Priority
?
2,619 Views
Last Modified: 2014-05-15
Just wondering if anyone has any experience modifying the ntSecurityDescriptor property of an Active Directory object from a non-microsoft language (specifically, using python-ldap)?

I am using python-ldap to create user accounts and I need to set the "user cannot change password" property on the new accounts.  Unfortunately, the Microsoft documentation states that you cannot set this property by modifying the userAccountControl attribute directly and must instead pull the DACL object (which is contained within the ntSecurityDescriptor property), and modify a permission setting in there. They have some example code for doing it using a built-in class in Visual Basic, but I'm looking to modify this property directly from python.

Microsoft's documentation on this is here:

http://msdn.microsoft.com/en-us/library/aa746398(v=vs.85).aspx

Would greatly appreciate any assistance on this!
0
Comment
Question by:rmeany
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 83

Expert Comment

by:David Johnson, CD, MVP
ID: 40024775
It is a lot easier using the winnt provider
http://msdn.microsoft.com/en-us/library/aa746399%28v=vs.85%29.aspx
0
 

Author Comment

by:rmeany
ID: 40024869
Sorry, I should have also mentioned that I am running this python on a linux server, so I have no access to win32 com objects
0
 

Author Comment

by:rmeany
ID: 40024960
Looks like my only option is to edit the nTSecurityDescriptor byte structure directly.  I was having trouble accessing the nTSecurityDescriptor attribute until I found out that it can only be queried using an account with Domain Administrator privileges.. I don't like giving domain admin privileges to a service account, but oh well...

I found documentation describing the structure of nTSecurityDescriptor here:

http://msdn.microsoft.com/en-us/library/cc230366.aspx

I plan to write a function that pulls the DACL bytes, finds within that any ACE entry bytes representing CHANGE_PASSWORD_GUID and sets the ACE entry byte values appropriately (ADS_ACETYPE_ACCESS_DENIED_OBJECT or ADS_ACETYPE_ACCESS_ALLOWED_OBJECT) for any entries with SID bytes that match the SIDs for "Everyone" and "NT Authority\SELF"
0
 

Accepted Solution

by:
rmeany earned 0 total points
ID: 40056717
0
 

Author Closing Comment

by:rmeany
ID: 40066736
The code I wrote allows you to read and manipulate the security descriptor on AD objects via python-ldap
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

Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
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…

618 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