Solved

read-only access

Posted on 2002-04-23
2
144 Views
Last Modified: 2010-05-02
Hai,

I'm using the functions below to find some directory in which a user has write access. However, in a map with 50 subdirectories where the user only has write access to 5 of them I find the procedure to slow.

Does someone know a quicker way to check for write access to the sub maps?

(BTW, yes, most of the functions came out of VBA help files  ;-)   )

Function Make_List() As String
Dim MyPath As String, MyName As String, maplist As String
  MyPath = "f:\data\"
  MyName = Dir(MyPath, vbDirectory)
  Do While MyName <> ""
    If MyName <> "." And MyName <> ".." Then
      If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
            If check_access(MyPath & MyName & "\") Then maplist = maplist & "," & MyName
      End If
    End If
    MyName = Dir
  Loop
  Make_List = Right(maplist, Len(maplist) - 1)
End Function

Private Function check_access(pad As String) As Boolean
  On Error GoTo handler
  Open pad & "TESTFILE" For Output As #1
  Close #1
  Kill pad & "TESTFILE"
  check_access = True
  Exit Function
handler:
  check_access = False
End Function

Kind regards
0
Comment
Question by:ehout
2 Comments
 
LVL 3

Accepted Solution

by:
Elmo_ earned 150 total points
ID: 6962315
ehout,

If you goto the following website you should get everything you need and more.

http://www.allapi.net/apilist/apifunction.php?apifunction=GetFileSecurity

This API should allow you to identify the security type on the folders you are checking.

There is also an example of how to get the Security Type and Change it.

Hope this helps.

0
 
LVL 3

Author Comment

by:ehout
ID: 7069801
Hi,

Indeed it seems to do the trick. However I'm not a hardcore programmer (though willing to learn). Could you or someone please tell me how to use that function?

The ntfs example seems a bit complex to me.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question