[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 176
  • Last Modified:

Howto get the file permissions in a Windows 2000/XP

I want to get the permissions defined for the files stored in a Windows 2000 or in a Windows XP within a Visual Basic 6.0 program.

How can I get them?

Thanks. :)
0
gllanderas
Asked:
gllanderas
  • 5
  • 2
  • 2
  • +1
1 Solution
 
gllanderasAuthor Commented:
Thanks, sajuks, but when I run this code:

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_10194747.html

I see this at the debug window:

0 - 0 -  - Change
0 - 0 -  - Read
0 - 0 -  - Read

If I run this:

   ACEs = GetAccessControlElements("C:\test.txt", SE_FILE_OBJECT)
   With ACEs
      For I = 0 To UBound(.List)
         With .List(I)
            Debug.Print .TRUSTEE.TrusteeForm & " - " & .TRUSTEE.TrusteeType & " - " & .TRUSTEE.ptstrName & " - " & AccessRights(.grfAccessMode, .grfAccessPermissions)
            Debug.Print "   " & Len(.TRUSTEE.ptstrName) & " - " & Asc(Mid(.TRUSTEE.ptstrName, 1, 1)) & " - " & Asc(Mid(.TRUSTEE.ptstrName, 2, 1)); ""
         End With
      Next
   End With

I obtain this:

0 - 0 -  - Change
   2 - 1 - 5
0 - 0 -  - Read
   2 - 1 - 5
0 - 0 -  - Read
   2 - 1 - 2


Any ideas? I need to obtain the name of the user who has permissions defined in the file.
0
 
sajuksCommented:
i thought u just wanted to know what permission had been set on the file....sorry
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
_lv_Commented:
Try to read these mskb:
(How To Use (High/ Low)-Level Access Control APIs from Visual Basic)
http://support.microsoft.com/kb/295004/EN-US/
http://support.microsoft.com/default.aspx?scid=kb;en-us;316440
0
 
gllanderasAuthor Commented:
lv, the low-level access control APIs should be used only on Windows NT 4.0-and-earlier operating systems. See the note of the article of Microsoft.
http://support.microsoft.com/default.aspx?scid=kb;en-us;316440


And with the other article, http://support.microsoft.com/kb/295004/EN-US/
I can change the permissions, but the problem is when I try to get present permissions of the file.

I think the problem is at GetExplicitEntriesFromAcl API function. :-(

Thanks, anyway.
0
 
gllanderasAuthor Commented:
Yes, sajuks, I want to know what permissions had been set... and the login (or SID) of the user. Something like:

everyone: read
administrator: write
MiPC\Guiller: write

0
 
_lv_Commented:
Well...from those resources you should have reached:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthz/security/buildexplicitaccesswithname.asp

"Unwinding" structure by structure, calling function by function you could get the desired result.
But there is another (more effortless) possibility - use microsoft cacls.exe or xcacls.exe utility.
0
 
gllanderasAuthor Commented:
Well, I will try xcalcs.exe, then.

The question is that this will be a server process called by various clients simultaneously, so I prefer to use API calls instead of calling a command line program (and capturing the output).

I will wait a few days until try xcalcs.exe. Perhaps somebody knows why fails the code at

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_10194747.html
0
 
gllanderasAuthor Commented:
I have found another way to get the file permissions: ussing winmgmts.

http://www.microsoft.com/technet/scriptcenter/scripts/security/dacls/sedcvb01.mspx

This works fine. :)
0
 
PAQ_ManCommented:
Question Closed, 500 points refunded.
PAQ_Man
Community Support Moderator
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 5
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now