Avatar billede cc2000 Nybegynder
30. juli 2002 - 08:30 Der er 34 kommentarer og
2 løsninger

Hvordan sætter man sikkerhed på en database?

Nu har jeg prøvet frem og tilbage og læst en del men kan bare ikke finde ud af at sætte sikkerhed på databasen.
Eller jo hvis alle bruger den samme workgroup file. Men det er jo ikke meningen.

Inden jeg holdte sommerferie mener jeg at jeg fik det til at virke som det skulle. Men nu virker det ikke. Jeg er lost.

Det er Access 2000 jeg bruger.
Avatar billede karstenlaursen Nybegynder
30. juli 2002 - 08:37 #1
Under funktioner og sikkerhed kan du lave en masse sikkerhed på din database!
Avatar billede terry Ekspert
30. juli 2002 - 08:50 #2
1. Create a new workgroup using the Workgroup Admin. Tool. (C:\WINNT\system32\WRKGADM.EXE)
2. Open Access, signing on as Admin user.
3. Open the database you want to secure.
4. Add a new admin user. Use for example: Application Name + Admins
5. Add the Admins group to the new Admin user.
6. Change the Admin password.
7. Change User Group permissions to be No Run/Open, No Open Exclusive, and  No Administrator on the database object.
8. Close Access.
9. Reopen Access, this time sign on as the new Admin user.
10. Open the database you are securing.
11. Run the security wizard on the database. Making sure that you select all objects in the first dialog box.
12. When the wizard has finished, close Access again.
13. Reopen Access, this time sign on as the new Admin user.
14. Open the database you are securing.
15. Remove the Admins group for the Admin user. This action ensures that any user who opens that database without using the correct workgroup file can’t see any of the database objects.
16. Add the groups that will be required for the database.
17. Add all users to their correct groups.
18. Assign permissions to the groups as required.
19. As new objects are added, add or remove the permissions as required.

This workgroup file (system.mdw) must accompany  your database. To start your database using this workgroup file and not the default you must use a shortcut to open your database.
Avatar billede terry Ekspert
30. juli 2002 - 08:52 #3
the shortcut should look something like this
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE"  /wrkgrp "D:\SomePath\system.mdw" "D:\SomePath\YourSecureDB.mdb"
Avatar billede cc2000 Nybegynder
30. juli 2002 - 09:15 #4
Terry... if i do as you say. And someone opens the database without the workgroup file that i made. Does this then prevent them from opening it or what?

The system.mdw you referer to is this the workgroup file i just made in step 1?

If i do as you say, and open the database with the shortcut. Does everyone then log in automatically? Or what?

I need to be able to open the database without entering any username or password where the only thing you can is read everything and be able to add, delete, update a table.

Is there a way to prevent users from opening the window where you can view, create and delete tables, forms, queries, reports, and so on.
Avatar billede terry Ekspert
30. juli 2002 - 09:25 #5
Yes if they do NOThave the workgroupp file then they can NOT open it.
Yes (step 1).
No they will be prompted for a password!


You can open the database using a shortcut AND including the user name and password but there is NOT much security in this method.

You can make an MDE file and hide the database window and perhaps remove standard menu's but it is still possible to open the dB by holding the shift key when opening the dB. There are ways to remove this though.
Avatar billede terry Ekspert
30. juli 2002 - 09:36 #6
Avatar billede cc2000 Nybegynder
30. juli 2002 - 09:57 #7
Terry ... I need to let the program log in automatic or use the shortcut to do that, because this program will be send out to thousands of users and they all should have the possibility to use the program without entering username and password.

How should the shortcut look like if it should use a username and password and include the workgroupfile? :)
Avatar billede terry Ekspert
30. juli 2002 - 10:05 #8
If your program is to be used by 1000's of users then I HOPE you are NOT using Access as the backend (data) database?

Access has a maximum (theoretical) 255 users!

So IF you are using for example MS SQL Server then it would be an idea to use SQL Server/NT security for logging on.

If you have MS Office Developer then you can make a setup-kit which will include a runtime version of Access. This saves you having to have a license for ALL users. It also makse it possible to secure your database better. When using the runtime it isnt possible to open the dB and alter the DESIGN.

IF you are just trying to stop them from altering the design then forget using Access security and make a setup-kit as I suggest here!
Avatar billede cc2000 Nybegynder
30. juli 2002 - 10:12 #9
All customers get the database each. Not a single database for all users.
I dont have MS Office Developer so i cant make use of the runtime version of access.
Avatar billede terry Ekspert
30. juli 2002 - 10:30 #10
So you are saying they have their own data?

OK, I suggest that you FORGET Access security!
You should distribute an MDE file and NOT an MDB file. This stops anyone going into any VBA code.

You can HIDE the database window in the setup options menu. and you can also make your own menu and use this instead of the standard menu.
Then make a shortcut similar to the one I mention but remove the workgroup part. Now add a paramater

/runtime

This starts Access in RUNTIME mode and by doing this stops people playing around. They can STILL open the dB directly if they know how, but you can use the method in the link I sent to stop them using the shift key to bypass the startup.
Avatar billede cc2000 Nybegynder
30. juli 2002 - 10:40 #11
Terry ... i got the vba code to how to disable it. But how do i get it to run at startup?
I think it will be the last question :)
Avatar billede terry Ekspert
30. juli 2002 - 10:48 #12
make a macro and name it autoexec

Access looks for autoexec when it starts
Avatar billede juks Novice
30. juli 2002 - 10:52 #13
kan man ikke selvom man ikke har Developer. Indtaste et password i vb-editoren så man ikke kan ændre/se vb koden uden dette
Avatar billede cc2000 Nybegynder
30. juli 2002 - 10:52 #14
Okay. But shift key disables autoexec? How can it then run some code?
In autoexec should i use runcode? What should i write in the field?
Avatar billede cc2000 Nybegynder
30. juli 2002 - 10:53 #15
juks ... jo kan man godt. Men det gælder også andet end kun vba'en som man ikke skal kunne se.
Avatar billede juks Novice
30. juli 2002 - 10:58 #16
hvorfor køber du ikke Developer ?
shift tasten kan sagtens gøres ukampdygtig ! prøv at søge i ms-knowledgebase der ligger den kode lige til at nappe.  ellers har terry den sikkert.
Avatar billede cc2000 Nybegynder
30. juli 2002 - 10:59 #17
Juks ... har fået fat på koden. Men jeg fatter ikke hvordan man får den til at køre under opstarten ;)
Avatar billede henrik13 Nybegynder
30. juli 2002 - 11:00 #18
Hvis det har interesse, kan du også få password, på hvert enkelt formular. Dvs din åbningsformular, lægger du også password på. Så kan den også åbnes ved maskinskift.
Vh Henrik
Avatar billede juks Novice
30. juli 2002 - 11:07 #19
nu kender jeg ikke din code men skal vel køres i en autoexec prøv lige at poste koden her ..
Avatar billede terry Ekspert
30. juli 2002 - 11:15 #20
The shift key can By-pass autoexec.

What did you write (mean) here? "Terry ... i got the vba code to how to disable it. "
Avatar billede cc2000 Nybegynder
30. juli 2002 - 11:18 #21
Terry ...
I meant i got the vba code to disable the shift key. But doesnt know how to run it at startup.
You told me to run it in autoexec. But how can autoexec run the code to disable shift if i hold the shift key down while opening the database?
Avatar billede cc2000 Nybegynder
30. juli 2002 - 11:19 #22
The code to disable shift-key:


Sub SetStartupProperties()
Const DB_Text As Long = 10
Const DB_Boolean As Long = 1
    ChangeProperty "StartupForm", DB_Text, "Customers"
    ChangeProperty "StartupShowDBWindow", DB_Boolean, False
    ChangeProperty "StartupShowStatusBar", DB_Boolean, False
    ChangeProperty "AllowBuiltinToolbars", DB_Boolean, False
    ChangeProperty "AllowFullMenus", DB_Boolean, True
    ChangeProperty "AllowBreakIntoCode", DB_Boolean, False
    ChangeProperty "AllowSpecialKeys", DB_Boolean, False
    ChangeProperty "AllowBypassKey", DB_Boolean, False
End Sub

Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
    Dim dbs As Object, prp As Variant
    Const conPropNotFoundError = 3270

    Set dbs = CurrentDb
    On Error GoTo Change_Err
    dbs.Properties(strPropName) = varPropValue
    ChangeProperty = True

Change_Bye:
    Exit Function

Change_Err:
    If Err = conPropNotFoundError Then    ' Property not found.
        Set prp = dbs.CreateProperty(strPropName, _
            varPropType, varPropValue)
        dbs.Properties.Append prp
        Resume Next
    Else
        ' Unknown error.
        ChangeProperty = False
        Resume Change_Bye
    End If
End Function
Avatar billede cc2000 Nybegynder
30. juli 2002 - 11:21 #23
I just tried to make a MDE file but it failed with the message that it couldnt create it. (Hate this types of messages)
Avatar billede juks Novice
30. juli 2002 - 11:24 #24
prøv at kompilere coden og  komprimerer og rep. dben inden du laver mde
Avatar billede cc2000 Nybegynder
30. juli 2002 - 11:28 #25
Juks... takker... :) Underligt. Den fejlede under compile. Men koden virkede godt nok før.
Avatar billede terry Ekspert
30. juli 2002 - 11:29 #26
you are supposed to run the code once to set the startup properties. The autoexec should just open your startup form for example.
Avatar billede cc2000 Nybegynder
30. juli 2002 - 11:31 #27
Terry ... okay. And if i run the code once. The properties will be saved in the database and not the access program?
Avatar billede terry Ekspert
30. juli 2002 - 12:11 #28
They will be saved in the current dB
Avatar billede cc2000 Nybegynder
30. juli 2002 - 12:15 #29
Okay :)
Can you tell me why if i enable standard toolbar its only visible on my machine. Not the other machines?
Avatar billede terry Ekspert
30. juli 2002 - 12:20 #30
You have to make a NEW menu and set this as the default
Avatar billede cc2000 Nybegynder
30. juli 2002 - 12:38 #31
Where can i make a new menu? Cant find it.
Avatar billede terry Ekspert
30. juli 2002 - 12:42 #32
This is taken from Access (97)Help
Create a custom menu bar for the current database

1    On the View menu, point to Toolbars, and then click Customize.
2    On the Toolbars tab, click New.
3    In the Toolbar Name box, type the name you want, and then click OK.
4    On the Toolbars tab, click Properties.
5    In the Type list, click Menu Bar.
6    Set any other properties you want, and then click Close.

The new menu bar is now behind the Customize dialog box. To see the new menu bar, move the Customize dialog box to the side, and then proceed to step 7.

7    To complete the menu bar, do the following:

·    Add custom menus. For more information, click  .
·    Add a built-in menu. For more information, click  .

Notes 

·    Microsoft Access still supports menu bar macros for applications created with a prior version of Microsoft Access. For more information, click  .
·    You can attach the custom menu bar to a form or report. For more information, click  . Or, you can designate the bar as the global menu bar. For more information, click  .
Avatar billede cc2000 Nybegynder
30. juli 2002 - 12:43 #33
I cant access customize. Its grayed out.
Avatar billede cc2000 Nybegynder
30. juli 2002 - 12:45 #34
found the problem. I had disabled, toolbar and menu changes. Doooh :)
Avatar billede cc2000 Nybegynder
30. juli 2002 - 13:35 #35
Tnx for the help!
Tak for hjælpen!
:)
Avatar billede terry Ekspert
30. juli 2002 - 13:37 #36
selv tak:o)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester