Solved

Modifying Active Directory ntSecurityDescriptor property in python-ldap

Posted on 2014-04-26
5
2,329 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
  • 4
5 Comments
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
0
 

Author Closing Comment

by:rmeany
Comment Utility
The code I wrote allows you to read and manipulate the security descriptor on AD objects via python-ldap
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Article by: Swadhin
Introduction of Lists in Python: There are six built-in types of sequences. Lists and tuples are the most common one. In this article we will see how to use Lists in python and how we can utilize it while doing our own program. In general we can al…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now