c# - Get domain groups for a specified user and permissions for a specified file using .Net -


I want to return a list of group membership for a specific domain user. In some way ...

  string [] user group (string domain, string domain username) {// query domain information // a list of accounts is a member of the user back}  

In addition, I want to be able to see which domain accounts / groups have access to a specific file / folder.

  string [] Allowed Subscribers (string domain, string filePath) {// query file / folder permission} Returns a list of accounts with logging in to the file / folder}  

What is the best way to do these two tasks using C #?

Here's an example. You do not need a domain for file access function, unless you want to filter.

  string [] user group (string domain, string domain username) {WindowsIdentity ident = new WindowsIdentity (domainUserName + "@" + domain); & Lt; String & gt; Group = new list & lt; String & gt; (); Leading (ident.reference in the identity group) {groups.Add (g.Value); } Return group. Tore (); } String [] allowed access (string filespath) {list & lt; String & gt; Accounts = new list & lt; String & gt; (); FileinfoFINOE = new fileinfo (filepath); Var fsec = fInfo.GetAccessControl (); Authorization rule collection acl = fsec.getAccessRules (true, true, typef (System.Security.Principal.NTAccount)); Foreign exchange (access to ACL system file system) {accounts.Add (ace.IdentityReference.Value); } Return Account .ORA (); }  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -