using System; using System.Collections.Generic; using System.Text; using System.DirectoryServices; using System.DirectoryServices.AccountManagement; using System.DirectoryServices.ActiveDirectory; using System.Security.Permissions; using System.Security.Principal; using System.Security.AccessControl; namespace Adscript { class Program { public void getresellerous() { // DirectoryEntry objde = new DirectoryEntry("LDAP;//OU="'+ reseller +'",OU=Hosting,DC="'++'"); DirectoryEntry objde = new DirectoryEntry("LDAP://OU=res1.test1,OU=Hosting,DC=ninad,DC=dev"); DirectorySearcher objderctorysearch = new DirectorySearcher(objde); // SearchResultCollection objserch; objderctorysearch.Filter = "(objectClass=organizationalUnit)"; objderctorysearch.SearchScope = SearchScope.Subtree; foreach (SearchResult res in objderctorysearch.FindAll()) { // this.setpermission(); // //Console.WriteLine("found::" + res.Properties["distinguishedName"].ToString ); //} NTAccount res1 = new NTAccount("ninad", "Authenticated Users"); ActiveDirectoryAccessRule readrule = new ActiveDirectoryAccessRule(res1, ActiveDirectoryRights.ReadProperty, AccessControlType.Allow, ActiveDirectorySecurityInheritance.None); objde.ObjectSecurity.AddAccessRule(readrule); objde.CommitChanges(); objde.Close(); objde.Dispose(); } } static void Main(string[] args) { Program pr = new Program(); pr.getresellerous(); Console.ReadLine(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)