Problem with granting permission to users

sabas
02-04-2004, 12:52 AM
Hi,

I wish to grant full control to users, so I create a batch file named permission.bat with 1 line of code as follows:
echo y|cacls C:\Program Files\myFolder\myFile.mdb /E /G Users:F

and I execute it in Form load:

Private sub Form_Load()
ShellExecute Me.hwnd, "Open", App.Path & "\permission.bat", "", "", 0
End Sub

My declaration for that:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

To see how it works I right click on the file (myFile.mdb), select Properties/Security tab/click on Users in Group or users name panel. The outcome is that users do not have full control as expected because the full control box was unchecked. Could anybody tell me what went wrong? (I'm using WinXP Pro).

Thanks,

couch612
02-04-2004, 06:49 PM
you can edit user permissions directly from VB using DAO code. this would be a better way to achieve what you are trying to do.

sabas
02-05-2004, 06:10 PM
Hi couch612, could you specify what I should do about it with DAO (code please)? I prefer using ADO, so can we do it with ADO?

couch612
02-05-2004, 07:16 PM
DAO example - this routine sets full permissions to the Users group for all form objects in a database:


Sub GrantAccess()

dim wrk as workspace
Dim db As Database
Dim i As Integer
Dim doc As Document
Dim strPrivilege As String

DBEngine.SystemDB = "[filename of your access .mdw file]"
DBEngine.DefaultUser = "[name of administrator user]"
DBEngine.DefaultPassword = "[administrator user password]"

set wrk = workspaces(0)
Set db = Wrk.OpenDatabase("mydb.mdb")

for i = 0 to db.containers("Forms").documents.count - 1

Set doc = gdb.Containers("Forms").Documents(i)
doc.UserName = "Users"
doc.Permissions = dbSecFullAccess

next i

End Sub

sabas
02-05-2004, 07:50 PM
Thanks, couch612

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum