Solved

read-only access

Posted on 2002-04-23
2
143 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now