473,513 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Assigning Security permission

19 New Member
I copied the code below from online and would like to incorporate in my access database security feature
but seems not not work. please help me

Expand|Select|Wrap|Line Numbers
  1. Public Function SetPermission2Grp(ByVal DatabaseName As String, ByVal groupname As String) As Boolean
  2. '-------------------------------------------------------------------------
  3. 'Author : a.p.r. pillai
  4. 'Date   : March-2010
  5. 'Purpose: To Assign Security Permissions to Objects
  6. '       : for a particular Security Group Account
  7. '       : in an external Database.
  8. 'Note   : The Security Group Account must be present
  9. '       : in the active Workgroup Information File
  10. '       :'Remarks: All Rights Reserved by www.msaccesstips.com
  11. '-------------------------------------------------------------------------
  12. Dim wsp As Workspace, db As Database, ctr As Container, doc As Document
  13. Dim ctrName As String, docName As String
  14. Dim L4 As String
  15. Const OBJSFULL = &HD01FE
  16. Const dbOpenRun = 2
  17. Const FrmRptOpenRun = 256
  18. Const MacOpenRun = 8
  19. Const TblQryExcludingModifyAdmin = 244 'All permissions Exluding Modify & Administr
  20. 'Assign Permissions to Group Account
  21. On Error GoTo SetPermission2Grp_Err
  22. Set wsp = DBEngine.Workspaces(0)
  23. Set db = wsp.OpenDatabase("SchoolMaster-Finance.accdb", _
  24.       True)
  25.  
  26. wsp.Groups.Refresh
  27. For Each ctr In db.Containers
  28. ctrName = ctr.Name
  29. ctr.UserName = groupname
  30. Select Case ctrName
  31. Case "Databases"
  32. For Each doc In ctr.Documents
  33.          docName = doc.Name
  34.          doc.UserName = groupname
  35.          Select Case docName
  36.            Case "MSysDb"
  37.              'Set Open/Run Permissions to Database Object
  38.               doc.Permissions = doc.Permissions Or dbOpenRun
  39.          End Select
  40.       Next doc
  41.    Case "Forms"
  42.     'Set Open/Run Permissions to Forms Container
  43.       ctr.Permissions = ctr.Permissions Or FrmRptOpenRun
  44.       ctr.Inherit = True
  45.       For Each doc In ctr.Documents
  46.          docName = doc.Name
  47.          doc.UserName = groupname
  48.          'Set Open/Run Permissions to Each Form
  49.         doc.Permissions = doc.Permissions Or FrmRptOpenRun
  50.       Next doc
  51.    Case "Reports"
  52.     'Set Open/Run Permissions to Reports Container
  53.       ctr.Permissions = ctr.Permissions Or FrmRptOpenRun
  54.       ctr.Inherit = True
  55.       For Each doc In ctr.Documents
  56.          docName = doc.Name
  57.          doc.UserName = groupname
  58.          'Set Open/Run Permissions to Each Report
  59.          doc.Permissions = doc.Permissions Or FrmRptOpenRun
  60.       Next doc
  61.    Case "Scripts"
  62.      'Set Open/Run Permissions to Macros Container
  63.       ctr.Permissions = ctr.Permissions Or MacOpenRun
  64.       ctr.Inherit = True
  65.       For Each doc In ctr.Documents
  66.          docName = doc.Name
  67.         doc.UserName = groupname
  68.          'Set Open/Run Permissions to Each Macro
  69.          doc.Permissions = doc.Permissions Or MacOpenRun
  70.       Next doc
  71.    Case "Tables"
  72.       '1. Assigns Full Permissions to Tables & Queries
  73.       ctr.Permissions = ctr.Permissions Or OBJSFULL
  74.       ctr.Inherit = True
  75.       For Each doc In ctr.Documents
  76.         docName = doc.Name
  77.         doc.UserName = groupname
  78.          L4 = Left$(docName, 4)
  79.        'Exclude System Objects
  80.         If L4 = "MSys" Or L4 = "~sq_" Then
  81.           GoTo nextloop
  82.         End If
  83.         '2. Remove Modify and Administrator permissions
  84.         doc.Permissions = doc.Permissions Or TblQryExcludingModifyAdmin
  85. nextloop:
  86.       Next doc
  87.   End Select
  88. Next
  89.  ctrSetPermission2Grp = False
  90. SetPermission2Grp_Exit:
  91. Set db = Nothing
  92. Set wsp = Nothing
  93. Exit Function
  94. SetPermission2Grp_Err:
  95. MsgBox Err & ": " & Err.Description, , "SetPermission2Grp"
  96. SetPermission2Grp = True
  97. Resume SetPermission2Grp_Exit
  98. End Function
  99. Public Function SetPer()
  100. Call SetPermission2Grp
  101.  
  102. End Function
Dec 27 '12 #1
5 3018
zmbd
5,501 Recognized Expert Moderator Expert
Emmanuel Ayivi:
Not enough detail to begin to answer question. Please read the FAQ, posting guidlines, and the stickies for the forum...

Normally, I would have deleted the thread; however, you did take the time to show what you're working with and it will take such a little amount of effort on your to have a good question!

At the minimum:
- What errors are you receiving, the EXACT number and text?
- Have you set the Option explicit and compare database?
- Have you compiled the code?
- Which version of access are you attempting to use this code with?
Dec 27 '12 #2
zmbd
5,501 Recognized Expert Moderator Expert
Found the original document.

This code will not work with "accdb" (native v2007/2010) databases as the user level security has been deprecated starting with v2007.

This is clearly stated in the associated articles to this code that Mr. Pillai has written in support.

This demonstrates the dangers of taking code, or other information, out of context without a clear understanding of the underlying structure/theory.
Dec 27 '12 #3
NeoPa
32,557 Recognized Expert Moderator MVP
This question is asked so poorly I wondered why it wasn't simply deleted. However, what we have now could well prove a very useful resource for those looking for similar help. Good work Z.
Dec 28 '12 #4
zmbd
5,501 Recognized Expert Moderator Expert
Part of the reason this wasn't out right deleted as I've been looking for a workaround myself for the user level security.

If one will run one of the database analysis tools (including the one in database-tools v2010) You can see that there is an owner "admin" and groups etc... assigned - > WITHIN <- an ACCDB file. I had hoped that someone had found a workaround wihtin Access to use these table properties! Reading OP's code, I didn't catch that the database reference had been modififed from the article code - leading me closer to the door with the lion, and I just had to take a peek at the lion. Pretty Kitty.
So, off to find OP's resource

and

a

deep

sigh.

No workaround. Instead an article dealing with mdb files from V2007. ARRRRRGGGGGGhhhhhhhhh -- where's me egg-nogg!
Dec 28 '12 #5
NeoPa
32,557 Recognized Expert Moderator MVP
As I said, it has proved a useful thread anyway (IMHO).

BTW. I'm not sure about that mess down your front Z, but it might explain the missing egg-nogg ;-)
Dec 28 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
529
by: Jason | last post by:
I am trying to write some code to parse file permissions, however I have run into some troubling problems No matter what language or method used to retrieve the accessmask property, if the value is...
3
2743
by: Chua Wen Ching | last post by:
Hi there, I had applied this security permissions in my class library based on fxcop standards. Before namespace: using System.Runtime.InteropServices; using System.Security.Permissions;
1
3439
by: Mohan | last post by:
Hi, I have developed a .NET Windows application. I able to run(Execute) it from the local drive of my PC. If I try to execute it from the SourceControl(Clear case) or from Shared drives, then it...
0
1056
by: Paul Riley | last post by:
Hello there all. Got a slight problem that is really starting to grate me. Have created a search page that interacts with the index service on one of our servers and it works wel... too well in...
0
1279
by: Nick Palmer | last post by:
Hi all, I've got what I think is a security/permission issue related to using the OWC 11 components on a Windows 2003 server running IIS 6.0. My web app has a client side Excel grid, and it...
0
1753
by: Brian Takita | last post by:
Hello, I'm getting the following error at the end of this message when trying to run the ReportManager and the ReportServer: Assembly system.data.dll security permission grant set is...
0
299
by: Prodip Saha | last post by:
Sorry about the cross-posting but I need to get attention from the ADO.Net and Web Service Gurus! I really need to use the System.Data.OleDb.OleDbParameter Class but I am getting following error...
9
1924
by: Johann Pietschnig | last post by:
Hi, My Problem: I have a C# EXE which writes a TXT file with results. It works perfect on my local computer, but when I try to run it from our network server (Drive G:), I am getting a...
6
5680
by: alex | last post by:
Hi, this always works: private ConsoleToTextbox myConsole; Console.SetOut(myConsole); But now (a few weeks later i started this project again) i get a non handeld security exception from...
0
731
by: Gouri.Mahajan7 | last post by:
Hello, I am importing "user32.dll" for calling the " Send Message" API in the user control for getting the line number in the richtext box. I am hosting this control on the web page. This works...
0
7166
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7386
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7543
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5689
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5094
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3236
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1601
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
459
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.