home *** CD-ROM | disk | FTP | other *** search
/ Master 95 #1 / MASTER95_1.iso / microsof / vbasic4 / vb4-6.cab / grpsusrs.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-07-26  |  23.4 KB  |  786 lines

  1. VERSION 4.00
  2. Begin VB.Form frmGroupsUsers 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Groups/Users/Permissions"
  5.    ClientHeight    =   5010
  6.    ClientLeft      =   1770
  7.    ClientTop       =   1815
  8.    ClientWidth     =   5760
  9.    Height          =   5415
  10.    HelpContextID   =   2016088
  11.    Icon            =   "GRPSUSRS.frx":0000
  12.    Left            =   1710
  13.    LinkTopic       =   "Form1"
  14.    LockControls    =   -1  'True
  15.    MaxButton       =   0   'False
  16.    MDIChild        =   -1  'True
  17.    MinButton       =   0   'False
  18.    ScaleHeight     =   5010
  19.    ScaleWidth      =   5760
  20.    Top             =   1470
  21.    Width           =   5880
  22.    Begin VB.ComboBox cboOwners 
  23.       Height          =   300
  24.       Left            =   3360
  25.       Style           =   2  'Dropdown List
  26.       TabIndex        =   28
  27.       Top             =   2360
  28.       Width           =   2295
  29.    End
  30.    Begin VB.Frame fraPermissions 
  31.       Caption         =   "Permissions"
  32.       Height          =   1695
  33.       Left            =   2520
  34.       TabIndex        =   16
  35.       Top             =   2760
  36.       Width           =   3135
  37.       Begin VB.CommandButton cmdAssign 
  38.          Caption         =   "&Assign"
  39.          Height          =   300
  40.          Left            =   120
  41.          TabIndex        =   25
  42.          Top             =   1280
  43.          Width           =   1400
  44.       End
  45.       Begin VB.CheckBox chkDeleteData 
  46.          Caption         =   "DeleteData"
  47.          Height          =   255
  48.          Left            =   1680
  49.          TabIndex        =   24
  50.          Top             =   1320
  51.          Width           =   1335
  52.       End
  53.       Begin VB.CheckBox chkInsertData 
  54.          Caption         =   "InsertData"
  55.          Height          =   255
  56.          Left            =   1680
  57.          TabIndex        =   23
  58.          Top             =   1000
  59.          Width           =   1335
  60.       End
  61.       Begin VB.CheckBox chkUpdateData 
  62.          Caption         =   "UpdateData"
  63.          Height          =   255
  64.          Left            =   1680
  65.          TabIndex        =   22
  66.          Top             =   680
  67.          Width           =   1335
  68.       End
  69.       Begin VB.CheckBox chkReadData 
  70.          Caption         =   "ReadData"
  71.          Height          =   255
  72.          Left            =   1680
  73.          TabIndex        =   21
  74.          Top             =   360
  75.          Width           =   1335
  76.       End
  77.       Begin VB.CheckBox chkAdminister 
  78.          Caption         =   "Administer"
  79.          Height          =   255
  80.          Left            =   120
  81.          TabIndex        =   20
  82.          Top             =   1000
  83.          Width           =   1455
  84.       End
  85.       Begin VB.CheckBox chkModifyDesign 
  86.          Caption         =   "ModifyDesign"
  87.          Height          =   255
  88.          Left            =   120
  89.          TabIndex        =   19
  90.          Top             =   680
  91.          Width           =   1575
  92.       End
  93.       Begin VB.CheckBox chkReadDesign 
  94.          Caption         =   "ReadDesign"
  95.          Height          =   255
  96.          Left            =   120
  97.          TabIndex        =   18
  98.          Top             =   360
  99.          Width           =   1455
  100.       End
  101.    End
  102.    Begin VB.OptionButton optGroups 
  103.       Caption         =   "Groups"
  104.       Height          =   255
  105.       Left            =   1200
  106.       TabIndex        =   2
  107.       Top             =   120
  108.       Width           =   975
  109.    End
  110.    Begin VB.OptionButton optUsers 
  111.       Caption         =   "Users"
  112.       Height          =   255
  113.       Left            =   120
  114.       TabIndex        =   1
  115.       Top             =   120
  116.       Value           =   -1  'True
  117.       Width           =   855
  118.    End
  119.    Begin VB.CommandButton cmdClose 
  120.       Caption         =   "&Close"
  121.       Height          =   375
  122.       Left            =   2160
  123.       TabIndex        =   0
  124.       Top             =   4560
  125.       Width           =   1335
  126.    End
  127.    Begin VB.ListBox lstTablesQuerys 
  128.       Height          =   1620
  129.       ItemData        =   "GRPSUSRS.frx":030A
  130.       Left            =   2520
  131.       List            =   "GRPSUSRS.frx":0311
  132.       MultiSelect     =   2  'Extended
  133.       TabIndex        =   15
  134.       Top             =   480
  135.       Width           =   3135
  136.    End
  137.    Begin VB.PictureBox picUsers 
  138.       Appearance      =   0  'Flat
  139.       BorderStyle     =   0  'None
  140.       ForeColor       =   &H80000008&
  141.       Height          =   3975
  142.       Left            =   120
  143.       ScaleHeight     =   3975
  144.       ScaleWidth      =   2205
  145.       TabIndex        =   3
  146.       Top             =   480
  147.       Width           =   2205
  148.       Begin VB.CommandButton cmdPassword 
  149.          Caption         =   "&Set/Clear Password"
  150.          Height          =   300
  151.          Left            =   120
  152.          TabIndex        =   26
  153.          Top             =   3615
  154.          Width           =   1935
  155.       End
  156.       Begin VB.ListBox lstUsersGroups 
  157.          Height          =   1035
  158.          Left            =   0
  159.          MultiSelect     =   1  'Simple
  160.          TabIndex        =   12
  161.          Top             =   2400
  162.          Width           =   2175
  163.       End
  164.       Begin VB.CommandButton cmdDeleteUser 
  165.          Caption         =   "&Delete"
  166.          Height          =   300
  167.          Left            =   1200
  168.          TabIndex        =   10
  169.          Top             =   1800
  170.          Width           =   975
  171.       End
  172.       Begin VB.CommandButton cmdNewUser 
  173.          Caption         =   "&New"
  174.          Height          =   300
  175.          Left            =   0
  176.          TabIndex        =   9
  177.          Top             =   1800
  178.          Width           =   975
  179.       End
  180.       Begin VB.ListBox lstUsers 
  181.          Height          =   1620
  182.          Left            =   0
  183.          TabIndex        =   4
  184.          Top             =   0
  185.          Width           =   2175
  186.       End
  187.       Begin VB.Label lblLabels 
  188.          Caption         =   "Groups Belonged to:"
  189.          Height          =   255
  190.          Index           =   1
  191.          Left            =   0
  192.          TabIndex        =   11
  193.          Top             =   2160
  194.          Width           =   2055
  195.       End
  196.    End
  197.    Begin VB.PictureBox picGroups 
  198.       Appearance      =   0  'Flat
  199.       BorderStyle     =   0  'None
  200.       ForeColor       =   &H80000008&
  201.       Height          =   3615
  202.       Left            =   120
  203.       ScaleHeight     =   3615
  204.       ScaleWidth      =   2205
  205.       TabIndex        =   5
  206.       Top             =   480
  207.       Visible         =   0   'False
  208.       Width           =   2205
  209.       Begin VB.ListBox lstGroupsUsers 
  210.          Height          =   1035
  211.          Left            =   0
  212.          MultiSelect     =   1  'Simple
  213.          TabIndex        =   13
  214.          Top             =   2400
  215.          Width           =   2175
  216.       End
  217.       Begin VB.CommandButton cmdDeleteGroup 
  218.          Caption         =   "&Delete"
  219.          Height          =   300
  220.          Left            =   1200
  221.          TabIndex        =   8
  222.          Top             =   1800
  223.          Width           =   975
  224.       End
  225.       Begin VB.CommandButton cmdNewGroup 
  226.          Caption         =   "&New"
  227.          Height          =   300
  228.          Left            =   0
  229.          TabIndex        =   7
  230.          Top             =   1800
  231.          Width           =   975
  232.       End
  233.       Begin VB.ListBox lstGroups 
  234.          Height          =   1620
  235.          Left            =   0
  236.          TabIndex        =   6
  237.          Top             =   0
  238.          Width           =   2175
  239.       End
  240.       Begin VB.Label lblLabels 
  241.          BackColor       =   &H00C0C0C0&
  242.          Caption         =   "Members:"
  243.          Height          =   255
  244.          Index           =   2
  245.          Left            =   120
  246.          TabIndex        =   14
  247.          Top             =   2160
  248.          Width           =   2055
  249.       End
  250.    End
  251.    Begin VB.Label lblLabels 
  252.       Caption         =   "Owner:"
  253.       Height          =   255
  254.       Index           =   3
  255.       Left            =   2520
  256.       TabIndex        =   27
  257.       Top             =   2400
  258.       Width           =   735
  259.    End
  260.    Begin VB.Label lblLabels 
  261.       Caption         =   "Tables/Querys:"
  262.       Height          =   255
  263.       Index           =   0
  264.       Left            =   2520
  265.       TabIndex        =   17
  266.       Top             =   165
  267.       Width           =   2055
  268.    End
  269.    Begin VB.Line Line1 
  270.       BorderWidth     =   3
  271.       X1              =   2400
  272.       X2              =   2400
  273.       Y1              =   120
  274.       Y2              =   4440
  275.    End
  276. Attribute VB_Name = "frmGroupsUsers"
  277. Attribute VB_Creatable = False
  278. Attribute VB_Exposed = False
  279. Option Explicit
  280. Dim mbSettingUser As Integer
  281. Dim mbSettingOwner As Integer
  282. Dim mbSettingPerm As Integer
  283. Dim mbLoading As Integer
  284. Dim mobjCurrObject As Object    'currently selected table or query
  285. Private Sub cboOwners_Click()
  286.   On Error GoTo COErr
  287.   'if we are setting thru code, just exit
  288.   If mbSettingOwner = True Then Exit Sub
  289.   If (mobjCurrObject.Permissions And dbSecWriteOwner) = dbSecWriteOwner Then
  290.     'try to set it
  291.     mobjCurrObject.Owner = cboOwners.Text
  292.   Else
  293.     MsgBox "You do not have permission to change the Owner!", 48
  294.     Exit Sub
  295.   End If
  296.   Exit Sub
  297. COErr:
  298.   ShowError
  299.   Exit Sub
  300. End Sub
  301. Private Sub chkAdminister_Click()
  302.   If mbSettingPerm = True Then Exit Sub
  303.   If chkAdminister.Value = 1 Then
  304.     'set all of them
  305.     chkReadDesign.Value = 1
  306.     chkModifyDesign.Value = 1
  307.     chkReadData.Value = 1
  308.     chkUpdateData.Value = 1
  309.     chkInsertData.Value = 1
  310.     chkDeleteData.Value = 1
  311.   End If
  312. End Sub
  313. Private Sub chkDeleteData_Click()
  314.   If mbSettingPerm = True Then Exit Sub
  315.   If chkDeleteData.Value = 0 Then
  316.     'unset others that need it
  317.     chkAdminister.Value = 0
  318.     chkModifyDesign.Value = 0
  319.   Else
  320.     chkReadDesign.Value = 1
  321.     chkReadData.Value = 1
  322.   End If
  323. End Sub
  324. Private Sub chkInsertData_Click()
  325.   If mbSettingPerm = True Then Exit Sub
  326.   If chkInsertData.Value = 0 Then
  327.     'unset others that need it
  328.     chkAdminister.Value = 0
  329.   Else
  330.     chkReadDesign.Value = 1
  331.     chkReadData.Value = 1
  332.   End If
  333. End Sub
  334. Private Sub chkModifyDesign_Click()
  335.   If mbSettingPerm = True Then Exit Sub
  336.   If chkModifyDesign.Value = 0 Then
  337.     'unset administer of them
  338.     chkAdminister.Value = 0
  339.   Else
  340.     chkReadDesign.Value = 1
  341.     chkReadData.Value = 1
  342.     chkInsertData.Value = 1
  343.     chkDeleteData.Value = 1
  344.   End If
  345. End Sub
  346. Private Sub chkReadData_Click()
  347.   If mbSettingPerm = True Then Exit Sub
  348.   If chkReadData.Value = 0 Then
  349.     'unset others that need it
  350.     chkAdminister.Value = 0
  351.     chkModifyDesign.Value = 0
  352.   Else
  353.     chkReadDesign.Value = 1
  354.   End If
  355. End Sub
  356. Private Sub chkReadDesign_Click()
  357.   If mbSettingPerm = True Then Exit Sub
  358.   If chkReadDesign.Value = 0 Then
  359.     'unset all of them
  360.     chkAdminister.Value = 0
  361.     chkModifyDesign.Value = 0
  362.     chkReadData.Value = 0
  363.     chkUpdateData.Value = 0
  364.     chkInsertData.Value = 0
  365.     chkDeleteData.Value = 0
  366.   End If
  367. End Sub
  368. Private Sub chkUpdateData_Click()
  369.   If mbSettingPerm = True Then Exit Sub
  370.   If chkUpdateData.Value = 0 Then
  371.     'unset others that need it
  372.     chkAdminister.Value = 0
  373.     chkModifyDesign.Value = 0
  374.   Else
  375.     chkReadDesign.Value = 1
  376.     chkReadData.Value = 1
  377.   End If
  378. End Sub
  379. Private Sub cmdAssign_Click()
  380.   SetPermissions True    'this will assign them
  381. End Sub
  382. Private Sub cmdClose_Click()
  383.   Unload Me
  384. End Sub
  385. Private Sub cmdDeleteGroup_Click()
  386.   On Error GoTo DGErr
  387.   Dim i As Integer
  388.   If lstGroups.ListIndex < 0 Then
  389.     Beep
  390.     MsgBox "No Group Selected!"
  391.     Exit Sub
  392.   End If
  393.   If MsgBox("Delete '" & lstGroups.Text & "'?", gnMSGBOX_TYPE) <> gnMSGBOX_YES Then Exit Sub
  394.   gwsMainWS.Groups.Delete lstGroups.Text
  395.   i = lstGroups.ListIndex
  396.   lstGroups.RemoveItem i
  397.   lstUsersGroups.RemoveItem i
  398.   If lstGroups.ListCount > 0 Then
  399.     lstGroups.ListIndex = 0
  400.   Else
  401.     'need to unselect all users
  402.     For i = 0 To lstGroupsUsers.ListCount - 1
  403.       lstGroupsUsers.Selected(i) = False
  404.     Next
  405.   End If
  406.   Exit Sub
  407. DGErr:
  408.   ShowError
  409.   Exit Sub
  410. End Sub
  411. Private Sub cmdDeleteUser_Click()
  412.   On Error GoTo DUErr
  413.   Dim i As Integer
  414.   If lstUsers.ListIndex < 0 Then
  415.     Beep
  416.     MsgBox "No User Selected!"
  417.     Exit Sub
  418.   End If
  419.   If MsgBox("Delete '" & lstUsers.Text & "'?", gnMSGBOX_TYPE) <> gnMSGBOX_YES Then Exit Sub
  420.   gwsMainWS.Users.Delete lstUsers.Text
  421.   lstUsers.RemoveItem lstUsers.ListIndex
  422.   If lstUsers.ListCount > 0 Then
  423.     lstUsers.ListIndex = 0
  424.   Else
  425.     'need to unselect all groups
  426.     For i = 0 To lstUsersGroups.ListCount - 1
  427.       lstUsersGroups.Selected(i) = False
  428.     Next
  429.   End If
  430.   Exit Sub
  431. DUErr:
  432.   ShowError
  433.   Exit Sub
  434. End Sub
  435. Private Sub cmdNewGroup_Click()
  436.   frmNewUserGroup.Caption = "New Group"
  437.   frmNewUserGroup.Show vbModal
  438. End Sub
  439. Private Sub cmdNewUser_Click()
  440.   frmNewUserGroup.Caption = "New User"
  441.   frmNewUserGroup.Show vbModal
  442. End Sub
  443. Private Sub cmdPassword_Click()
  444.   On Error GoTo CPErr
  445.   If lstUsers.Text = gwsMainWS.UserName Then
  446.     frmNewPassword.Show vbModal
  447.   Else
  448.     If MsgBox("Clear the Password for '" & lstUsers.Text & "'?", gnMSGBOX_TYPE) = gnMSGBOX_YES Then
  449.       gwsMainWS.Users(lstUsers.Text).NewPassword gsNULL_STR, gsNULL_STR
  450.     End If
  451.   End If
  452.   Exit Sub
  453. CPErr:
  454.   ShowError
  455.   Exit Sub
  456. End Sub
  457. Private Sub Form_Load()
  458.   On Error GoTo FLErr
  459.   Dim grp As GROUP
  460.   Dim usr As User
  461.   Dim i As Integer
  462.   CenterMe Me, gnMDIFORM
  463.   mbLoading = True
  464.   'add the groups and users
  465.   For Each usr In gwsMainWS.Users
  466.     lstUsers.AddItem usr.Name
  467.     lstGroupsUsers.AddItem usr.Name
  468.     cboOwners.AddItem usr.Name
  469.   Next
  470.   For Each grp In gwsMainWS.Groups
  471.     lstGroups.AddItem grp.Name
  472.     lstUsersGroups.AddItem grp.Name
  473.     cboOwners.AddItem grp.Name
  474.   Next
  475.   'set the 1st item if possible
  476.   If lstUsers.ListCount > 0 Then
  477.     lstUsers.ListIndex = 0
  478.   End If
  479.   If lstGroups.ListCount > 0 Then
  480.     lstGroups.ListIndex = 0
  481.   End If
  482.   'fill in the objects lists from the tables form
  483.   GetTableList lstTablesQuerys, True, False, False
  484.   mbLoading = False
  485.   lstTablesQuerys.Selected(0) = True
  486.   Screen.MousePointer = vbDefault
  487.   Exit Sub
  488. FLErr:
  489.   mbLoading = False
  490.   ShowError
  491.   Exit Sub
  492. End Sub
  493. Private Sub lstGroups_Click()
  494.   On Error GoTo GSErr
  495.   Dim i As Integer
  496.   mbSettingUser = True
  497.   For i = 0 To lstGroupsUsers.ListCount - 1
  498.     If IsMemberOf(lstGroups.Text, lstGroupsUsers.List(i)) Then
  499.       lstGroupsUsers.Selected(i) = True
  500.     Else
  501.       lstGroupsUsers.Selected(i) = False
  502.     End If
  503.   Next
  504.   mbSettingUser = False
  505.   Exit Sub
  506. GSErr:
  507.   ShowError
  508.   mbSettingUser = False
  509.   Exit Sub
  510. End Sub
  511. Private Sub lstGroups_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
  512.   If Button <> 2 Then Exit Sub
  513.   If SetPropItem(lstGroups, Y) = False Then Exit Sub
  514.   ShowProperties "Group", gwsMainWS.Groups(lstGroups.Text)
  515. End Sub
  516. Private Sub lstGroupsUsers_Click()
  517.   On Error GoTo GUErr
  518.   Dim usr As User
  519.   If mbSettingUser = True Then Exit Sub
  520.   If lstGroups.ListIndex < 0 Then
  521.     Beep
  522.     MsgBox "No Group Selected!"
  523.     Exit Sub
  524.   End If
  525.   If lstGroupsUsers.Selected(lstGroupsUsers.ListIndex) = True Then
  526.     'add the user to the group
  527.     Set usr = gwsMainWS.CreateUser(lstGroupsUsers.Text)
  528.     gwsMainWS.Groups(lstGroups.Text).Users.Append usr
  529.     gwsMainWS.Users(lstGroupsUsers.Text).Groups.Refresh
  530.   Else
  531.     'remove the user from the group
  532.     gwsMainWS.Groups(lstGroups.Text).Users.Delete lstGroupsUsers.Text
  533.     gwsMainWS.Users(lstGroupsUsers.Text).Groups.Refresh
  534.   End If
  535.   Exit Sub
  536. GUErr:
  537.   ShowError
  538.   Exit Sub
  539. End Sub
  540. Private Sub lstTablesQuerys_Click()
  541.   SetPermissions False
  542. End Sub
  543. Private Sub lstUsers_Click()
  544.   On Error GoTo USErr
  545.   Dim i As Integer
  546.   mbSettingUser = True
  547.   For i = 0 To lstUsersGroups.ListCount - 1
  548.     If IsMemberOf(lstUsersGroups.List(i), lstUsers.Text) Then
  549.       lstUsersGroups.Selected(i) = True
  550.     Else
  551.       lstUsersGroups.Selected(i) = False
  552.     End If
  553.   Next
  554.   mbSettingUser = False
  555.   'show permissions
  556.   SetPermissions False
  557.   Exit Sub
  558. USErr:
  559.   ShowError
  560.   mbSettingUser = False
  561.   Exit Sub
  562. End Sub
  563. Private Function IsMemberOf(rsGrp As String, rsUsr As String) As Integer
  564.   Dim usr As User
  565.   Dim grp As GROUP
  566.   Dim i As Integer
  567.   Set usr = gwsMainWS.Users(rsUsr)
  568.   For Each grp In usr.Groups
  569.     If grp.Name = rsGrp Then
  570.       IsMemberOf = True
  571.       Exit Function
  572.     End If
  573.   Next
  574.   IsMemberOf = False
  575. End Function
  576. Private Sub lstUsers_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
  577.   If Button <> 2 Then Exit Sub
  578.   If SetPropItem(lstUsers, Y) = False Then Exit Sub
  579.   ShowProperties "User", gwsMainWS.Users(lstUsers.Text)
  580. End Sub
  581. Private Sub lstUsersGroups_Click()
  582.   On Error GoTo UGErr
  583.   Dim grp As GROUP
  584.   If mbSettingUser = True Then Exit Sub
  585.   If lstUsers.ListIndex < 0 Then
  586.     Beep
  587.     MsgBox "No User Selected!"
  588.     Exit Sub
  589.   End If
  590.   If lstUsersGroups.Selected(lstUsersGroups.ListIndex) = True Then
  591.     'add the group to the user
  592.     Set grp = gwsMainWS.CreateGroup(lstUsersGroups.Text)
  593.     gwsMainWS.Users(lstUsers.Text).Groups.Append grp
  594.     gwsMainWS.Groups(lstUsersGroups.Text).Users.Refresh
  595.   Else
  596.     'remove the group from the user
  597.     gwsMainWS.Users(lstUsers.Text).Groups.Delete lstUsersGroups.Text
  598.     gwsMainWS.Groups(lstUsersGroups.Text).Users.Refresh
  599.   End If
  600.   Exit Sub
  601. UGErr:
  602.   ShowError
  603.   Exit Sub
  604. End Sub
  605. Private Sub optGroups_Click()
  606.   picUsers.Visible = False
  607.   picGroups.Visible = True
  608. End Sub
  609. Private Sub optUsers_Click()
  610.   picGroups.Visible = False
  611.   picUsers.Visible = True
  612. End Sub
  613. Private Sub SetPermissions(rbAssign As Integer)
  614.   On Error GoTo SPErr
  615.   Dim lPermissions As Long
  616.   Dim lPermissions2 As Long
  617.   Dim bUncommon As Integer    'multiselected flag for common permissions
  618.   Dim nCnt As Integer         'count of selected objects
  619.   Dim sUserGroup As String
  620.   Dim sObject As String
  621.   Dim i As Integer
  622.   mbSettingPerm = True
  623.   If rbAssign = True Then
  624.     'determine what permissions are set and Or them together
  625.     If chkReadDesign.Value = 0 Then
  626.       lPermissions = 0
  627.     Else
  628.       If chkAdminister.Value = 1 Then
  629.         'set them all
  630.         lPermissions = dbSecFullAccess Or _
  631.                        dbSecReadDef Or _
  632.                        dbSecWriteDef Or _
  633.                        dbSecRetrieveData Or _
  634.                        dbSecReplaceData Or _
  635.                        dbSecInsertData Or _
  636.                        dbSecDeleteData
  637.       Else
  638.         'set them one at a time
  639.         lPermissions = dbSecReadDef
  640.         If chkModifyDesign.Value = 1 Then
  641.           lPermissions = lPermissions Or dbSecWriteDef
  642.         End If
  643.         If chkReadData.Value = 1 Then
  644.           lPermissions = lPermissions Or dbSecRetrieveData
  645.         End If
  646.         If chkUpdateData.Value = 1 Then
  647.           lPermissions = lPermissions Or dbSecReplaceData
  648.         End If
  649.         If chkInsertData.Value = 1 Then
  650.           lPermissions = lPermissions Or dbSecInsertData
  651.         End If
  652.         If chkDeleteData.Value = 1 Then
  653.           lPermissions = lPermissions Or dbSecDeleteData
  654.         End If
  655.       End If
  656.     End If
  657.   End If
  658.   'determine if it's a user or a group
  659.   If optUsers.Value = True Then
  660.     'users
  661.     sUserGroup = lstUsers.Text
  662.   Else
  663.     'groups
  664.     sUserGroup = lstGroups.Text
  665.   End If
  666.   'set or get the permissions
  667.   If lstTablesQuerys.ListIndex = -1 Then
  668.     If mbLoading = False Then   'don't issue error on form load
  669.       Beep
  670.       MsgBox "No Object Selected!"
  671.     End If
  672.     Exit Sub
  673.   End If
  674.   'walk the object list and process the selected objects
  675.   For i = 0 To lstTablesQuerys.ListCount - 1
  676.     If lstTablesQuerys.Selected(i) = True Then
  677.       nCnt = nCnt + 1
  678.       If lstTablesQuerys.ListIndex = 0 Then
  679.         'must be <New Object>
  680.         gdbCurrentDB.Containers("Tables").UserName = sUserGroup
  681.         If rbAssign = False Then
  682.           lPermissions = gdbCurrentDB.Containers("Tables").Permissions
  683.         Else
  684.           gdbCurrentDB.Containers("Tables").Permissions = lPermissions
  685.         End If
  686.         ShowOwner gdbCurrentDB.Containers("Tables")
  687.         Set mobjCurrObject = gdbCurrentDB.Containers("Tables")
  688.       Else
  689.         sObject = StripConnect(lstTablesQuerys.List(i))
  690.         'a table ot query was selected
  691.         gdbCurrentDB.Containers("Tables").Documents(sObject).UserName = sUserGroup
  692.         If rbAssign = False Then
  693.           lPermissions = gdbCurrentDB.Containers("Tables").Documents(sObject).Permissions
  694.         Else
  695.           gdbCurrentDB.Containers("Tables").Documents(sObject).Permissions = lPermissions
  696.         End If
  697.         ShowOwner gdbCurrentDB.Containers("Tables").Documents(sObject)
  698.         Set mobjCurrObject = gdbCurrentDB.Containers("Tables").Documents(sObject)
  699.       End If
  700.       If nCnt > 1 Then
  701.         'if there is more than 1, they need to match or we set the flag
  702.         If lPermissions <> lPermissions2 Then
  703.           bUncommon = True
  704.         End If
  705.       End If
  706.       'store it for the next time through
  707.       lPermissions2 = lPermissions
  708.     End If
  709.   Next
  710.   If rbAssign = False Then
  711.     If bUncommon = True Then
  712.       'there was some mismatch so they need to be greyed
  713.       chkReadDesign.Value = 2
  714.       chkModifyDesign.Value = 2
  715.       chkAdminister.Value = 2
  716.       chkReadData.Value = 2
  717.       chkUpdateData.Value = 2
  718.       chkInsertData.Value = 2
  719.       chkDeleteData.Value = 2
  720.     Else
  721.       'there was either only one or they were all the same
  722.       'so we need to set them appropriately
  723.       If (lPermissions And dbSecReadDef) = dbSecReadDef Then
  724.         chkReadDesign.Value = 1
  725.       Else
  726.         chkReadDesign.Value = 0
  727.       End If
  728.       If (lPermissions And dbSecWriteDef) = dbSecWriteDef Then
  729.         chkModifyDesign.Value = 1
  730.       Else
  731.         chkModifyDesign.Value = 0
  732.       End If
  733.       If (lPermissions And dbSecFullAccess) = dbSecFullAccess Then
  734.         chkAdminister.Value = 1
  735.       Else
  736.         chkAdminister.Value = 0
  737.       End If
  738.       If (lPermissions And dbSecRetrieveData) = dbSecRetrieveData Then
  739.         chkReadData.Value = 1
  740.       Else
  741.         chkReadData.Value = 0
  742.       End If
  743.       If (lPermissions And dbSecReplaceData) = dbSecReplaceData Then
  744.         chkUpdateData.Value = 1
  745.       Else
  746.         chkUpdateData.Value = 0
  747.       End If
  748.       If (lPermissions And dbSecInsertData) = dbSecInsertData Then
  749.         chkInsertData.Value = 1
  750.       Else
  751.         chkInsertData.Value = 0
  752.       End If
  753.       If (lPermissions And dbSecDeleteData) = dbSecDeleteData Then
  754.         chkDeleteData.Value = 1
  755.       Else
  756.         chkDeleteData.Value = 0
  757.       End If
  758.     End If
  759.   End If
  760.   mbSettingPerm = False
  761.   Exit Sub
  762. SPErr:
  763.   mbSettingPerm = False
  764.   ShowError
  765.   Exit Sub
  766. End Sub
  767. Private Sub ShowOwner(vObj As Object)
  768.   On Error GoTo SOErr
  769.   Dim i As Integer
  770.   For i = 0 To cboOwners.ListCount - 1
  771.     If cboOwners.List(i) = vObj.Owner Then
  772.       mbSettingOwner = True
  773.       cboOwners.ListIndex = i
  774.       mbSettingOwner = False
  775.       Exit For
  776.     End If
  777.   Next
  778.   Exit Sub
  779. SOErr:
  780.   mbSettingOwner = True
  781.   cboOwners.ListIndex = -1
  782.   mbSettingOwner = False
  783.   ShowError
  784.   Exit Sub
  785. End Sub
  786.