• Iniciar sesión
  • Microsoft.com
  • España (Español)
    Brasil (Português)Česká republika (Čeština)Deutschland (Deutsch)France (Français)Italia (Italiano)United States (English)Россия (Русский)대한민국 (한국어)中华人民共和国 (中文)台灣 (中文)日本 (日本語)香港特别行政區 (中文)
 
 
Microsoft Developer Network
 
 
Inicio
 
 
Library
 
 
Aprendizaje
 
 
Descarga
 
 
Soporte
 
 
Comunidad
 
 
Foros
 
 
 
Microsoft Developer Network > Página principal de foros > Visual C# General > Enumerate file permissions
Formular una preguntaFormular una pregunta
Búsqueda de foros:
  • Buscar en el foro de Visual C# General Buscar en el foro de Visual C# General
  • Buscar en todos los foros de MSDN Buscar en todos los foros de MSDN
 

RespondidaEnumerate file permissions

  • miércoles, 10 de enero de 2007 11:37Sei_ Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    Votar como útil
    0

    Hello,

    First, I hope that I wrote my question in the right forum... If not, sorry by advance.  

    Well, I am searching for a way to list all members autorized to access a specific file or folder on the network. The application to create will have to be available for any user : meaning, for the moment, that I cannot use any admin account.

    My question is : do you know if such application can be developped in .Net ? C# ?

    If yes, could you please help me by indicating me the classes to use ? (I am not expert in this language, but I think that I can try to do something !)

    Thank you by advance.

    Sei.

    • ResponderResponder
    • CitarCitar
     

Respuestas

  • miércoles, 10 de enero de 2007 16:59TaylorMichaelLMVP, ModeradorMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Respondida
    Votar como útil
    0

    As of v2 you can use the security subsystem to enumerate the access rights of any securable object.  Firstly you'll need to get the file access rules.  Then  you can enumerate through them.  Here's some sample code that dumps the access rights of a file (folders work the same way but with different classes)

    static void Main ( string[] args )
    {
      
    FileSecurity sec = File.GetAccessControl(@"c:\temp");

      
    AuthorizationRuleCollection rules = sec.GetAccessRules(true, true, typeof(SecurityIdentifier));
      
    foreach (FileSystemAccessRule rule in rules)
       {
         
    NTAccount account = rule.IdentityReference.Translate(typeof(NTAccount)) as NTAccount;
         
    Console.Write("{0}: ", account.Value);

         
    if (rule.AccessControlType == AccessControlType.Deny)
            
    Console.Write("Denied ");
         
    Console.Write("{0}", rule.FileSystemRights);

         
    if (rule.IsInherited)
            
    Console.WriteLine(" (Inherited)");
         
    else
            
    Console.WriteLine(" (Explicit)");
       };
    }

    Michael Taylor - 1/10/07
    http://p3net.mvps.org

     

    • ResponderResponder
    • CitarCitar
     

Todas las respuestas

  • viernes, 16 de noviembre de 2007 17:26it68 Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    Votar como útil
    0

    This example does not cover situation when "rule.IdentityReference.Translate(typeof(NTAccount)) as NTAccount" throws an exception because SID can not be translated to NTAccount. This situation is very common when file share is exposed by a system that is not part of NT domain and uses CIFS or other type of file sharing.

     

    I found no ways so far to query if current application will have particular FileSystemRights permission on specific file.

     

    Is it achievable in C#?

     

    Igor Touzov 11/16/2007


     

    • ResponderResponder
    • CitarCitar
     
¿Necesita ayuda con los foros? (P+F)
 
© 2009 Microsoft Corporation. Reservados todos los derechos.
Administre su perfil
|
MSDN Flash en Español
|
Contacto
|
Aviso legal
|
Términos de uso
|
Marcas Registradas
|
Privacidad