CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    Sep 2008
    Posts
    4

    Reception of the rights to the catalogue

    There is such code. On a call dSecurity.ModifyAccessRule appears System.Security.Principal.IdentityNotMappedException
    What not so?
    Code:
     public void AddDirectorySecurity(string FileName, string Account, FileSystemRights Rights, AccessControlType ControlType)
            {
                // Create a new DirectoryInfo object.
                DirectoryInfo dInfo = new DirectoryInfo(FileName);
    
                // Get a DirectorySecurity object that represents the 
                // current security settings.
                DirectorySecurity dSecurity = dInfo.GetAccessControl();
                FileSystemAccessRule fsAccess = new FileSystemAccessRule(
                        Account, Rights,
                        InheritanceFlags.None,
                        PropagationFlags.NoPropagateInherit,
                        ControlType);
                bool allOK;
                dSecurity.ModifyAccessRule(AccessControlModification.Add, fsAccess, out allOK);
                if (!allOK)
                    throw new ApplicationException("Unable to add access rule to directory," + FileName + ", for " + Account);
    
                // Устанавливаем правила наследвания доступа
                FileSystemAccessRule inheritanceRule = new FileSystemAccessRule(
                        Account, Rights,
                        InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
                        PropagationFlags.InheritOnly,
                        ControlType);
                dSecurity.ModifyAccessRule(AccessControlModification.Add, inheritanceRule, out allOK);
                if (!allOK)
                    throw new ApplicationException("Unable to add inheritance rule to directory," + FileName + ", for " + Account);
    
                // Устанавливаем новые параметры доступа.
                dInfo.SetAccessControl(dSecurity);
    
    
            }

  2. #2
    Join Date
    Mar 2008
    Location
    IRAN
    Posts
    811

    Lightbulb Re: Reception of the rights to the catalogue

    Last edited by toraj58; November 19th, 2008 at 04:40 AM.
    Please rate my post if it was helpful for you.
    Java, C#, C++, PHP, ASP.NET
    SQL Server, MySQL
    DirectX
    MATH
    Touraj Ebrahimi
    [toraj_e] [at] [yahoo] [dot] [com]

  3. #3
    Join Date
    Sep 2008
    Posts
    4

    Re: Reception of the rights to the catalogue

    Well thanks

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured