Pergunta

I'm busy with a project where you can manage folder permissions of a shared drive from a portal (ASP.NET website). Is there any fast way to find specific permissions of a user in a folder structure? I Have a C#.NET service running on the file server.

This is what i try to archive:

Folder Structure:

RootFolder -> TestUser has special permission so user can navigate to Folder1
    -> Folder 1 --> TestUser has Read (local)
        -> Folder 1.1 --> TestUser has Read (inherited)
            -> Folder 1.1.1 --> TestUser has Read (local)

Now i remove TestUser from Folder 1, but when this happens i need to know if TestUser has permissions on a folder somewhere down in the structure and if this is the case i need to give Folder 1 AND Folder 1.1 special permissions so the user can navigate to Folder 1.1.1.

I have the complete folder structure and permissions in a database but only the read/write permissions not the special permissions (that give the user right to see a folder so he/she can navigate to a folder with read/write permissions). Now it would be great if I can do a quick search in the folder structure so see if the user has some permissions so I can clean up/add special permissions for the user (so user can navigate to all folder where he/she has read/write permissions).

I tried going trough the folder structure with Directory.GetDirectories(fullPath) and then for each directory the dir.GetAccessRules() method but this is very slow with big folder structures (10.000 folders).

I hope the question is clear and any suggestions would be appreciated!

Foi útil?

Solução

try to use

GetAccessRules(true, false, typeof(SecurityIdentifier))

and pre-translate your user account to SecurityIdentifier and search the access rule entries by this SID.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top