I want to test if an arbitrary user has write-access to attributes of a particular Active Directory object. I think one part of the solution appears to be this:
NTAccount Account = new NTAccount("Domain\\XYZ");
SecurityIdentifier Sid =
(SecurityIdentifier)Account.Translate(typeof(SecurityIdentifier));
That seems to allow me to get a concrete representation from a string representation of the user. Another piece of the puzzle I think is this:
string strMemberString = "LDAP://OU=Test,DC=Domain,DC=local";
DirectoryEntry computers = new DirectoryEntry();
computers.Path = strMemberString;
computers.Options.SecurityMasks = SecurityMasks.Owner | SecurityMasks.Group
| SecurityMasks.Dacl | SecurityMasks.Sacl;
foreach (DirectoryEntry computer in computers.Children)
{
if (computer.Name == "CN=Test")
{
ActiveDirectorySecurity sdc = computer.ObjectSecurity;
//...
Not sure where to go from there. How do I finish this? Is there an entirely different way I should be pursuing? I'm using .net 4.0.
I'd prefer that the solution be entirely BCL code, rather than PInvoke or WMI.