Click here to Skip to main content
16,022,737 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi i am trying to set a permission on one particullar ou and all child ou's under it for it's authenticated users to allow read permission..in active directory please reffer the following code and getting the "Some or all identity references could not be translated".please can anybody tell me how to implement it.

C#
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();
        }
    }
}
Posted

1 solution

anybody?????????????????who know this?????
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900