Attribute VB_Name = "sadbioexp"
Option Explicit

' Constants used in Access Control

Global Const PERFLAG_NOREL_NAME As String = "(None)" ' DEV_STRING
Global Const PERFLAG_NOVALUE    As Long = -1
Global Const PERFLAG_YES        As Long = -1
Global Const PERFLAG_NO         As Long = 0
Global Const PERFLAG_YES_NAME   As String = "Yes" ' DEV_STRING
Global Const PERFLAG_NO_NAME    As String = "No" ' DEV_STRING




' Permission Status i.e. assigned or inherited to a user or role
' For a Permission as a whole, all states are valid, but
'Assigned and Partially assigned are mutually exclusive, and
'Inherited and Partially inherited are mutually exclusive.
' For a Permission value, all states but the Partial states are valid
Global Const PERSTATUSFLAG_ASSIGNED                     As Integer = 1
Global Const PERSTATUSFLAG_INHERITED                    As Integer = 2
Global Const PERSTATUSFLAG_PARTIALLY_ASSIGNED           As Integer = 4
Global Const PERSTATUSFLAG_PARTIALLY_INHERITED          As Integer = 8
' Partial states only arise when enquiring about a permission in general,
'and not when supplying a specific permission value.

    ' Possible states:
    ' 'local' refers to the user or role object being queried
    ' 'inherit' refers to the user or role object which 'local' inherits from
    ' 0 means a value is not set
    ' 1 means a value is set
    ' all examples refer to definition permissions, whose set of values is Read and Write
    
    ' Neither assigned nor inherited
    ' e.g. def perms
    '           R   W
    ' inherit   0   0
    ' local     0   0

    ' Partially inherited:
    ' Only used when enquiring about a permission in general and not
    'supplying a specific value
    ' A value is inherited, but does not mean that the permission is fully inherited
    ' e.g. def perms
    '           R   W
    ' inherit   1   0
    ' local     0   0

    ' Partially assigned:
    ' Only used when enquiring about a permission in general and not
    'supplying a specific value
    ' A value is assigned, but does not mean that the permission is fully assigned
    ' e.g. def perms
    '           R   W
    ' inherit   0   0
    ' local     1   0
    
    ' Inherited:
    ' When enquiring about a permission in general, this means that the
    'permission is fully inherited:
    ' e.g. def perms
    '           R   W
    ' inherit   1   1
    ' local     0   0
    ' When enquiring about a specific permission value, this means that the
    'permission value is inherited:
    ' e.g. def perms, Read
    '           R   W
    ' inherit   1   0
    ' local     0   0

    ' Assigned:
    ' When enquiring about a permission in general, this means that the
    'permission is fully assigned:
    ' e.g. def perms
    '           R   W
    ' inherit   0   0
    ' local     1   1
    ' When enquiring about a specific permission value, this means that the
    'permission value is assigned:
    ' e.g. def perms, Read
    '           R   W
    ' inherit   0   0
    ' local     1   0

    ' Partially Assigned and Partially Inherited
    ' Only used when enquiring about a permission in general and not
    'supplying a specific value
    ' A value is inherited, but does not mean that the permission is fully inherited
    ' A different value is assigned, but does not mean that the permission is fully assigned
    ' e.g. def perms
    '           R   W
    ' inherit   1   0
    ' local     0   1
    
    ' Partially Assigned and Inherited
    ' Only used when enquiring about a permission in general and not
    'supplying a specific value
    ' A value is assigned, but does not mean that the permission is fully assigned
    ' The permission is fully inherited
    ' e.g. def perms
    '           R   W
    ' inherit   1   1
    ' local     1   0
    
    ' Assigned and Partially Inherited
    ' Only used when enquiring about a permission in general and not
    'supplying a specific value
    ' A value is inherited, but does not mean that the permission is fully inherited
    ' The permission is fully assigned
    ' e.g. def perms
    '           R   W
    ' inherit   1   0
    ' local     1   1
    
    ' Assigned and Inherited
    ' When enquiring about a permission in general, this means that the
    'permission is fully assigned and fully inherited:
    ' e.g. def perms
    '           R   W
    ' inherit   1   1
    ' local     1   1
    ' When enquiring about a specific permission value, this means that the
    'permission value is assigned:
    ' e.g. def perms, Read
    '           R   W
    ' inherit   1   0
    ' local     1   0



' Permission Types
Global Const MAXPERMISSIONTYPES As Integer = 6
 
Global Const PER_MENU           As Integer = 0  ' This permission relates to menu items (By ID)
Global Const PER_DIAGRAM        As Integer = 1  ' This permission relates to diagram types (By Type ID)
Global Const PER_SYMBOL         As Integer = 2  ' This permission relates to symbol types (By Type ID)
                                                ' PLACEHOLDER; there are no symbol permission values per se
Global Const PER_DEFINITION     As Integer = 3  ' This permission relates to definition types (By Type ID)
Global Const PER_MACRO          As Integer = 4  ' This permission relates to macro items (By macro name)
Global Const PER_CATALOG        As Integer = 5  ' This permission relates to catalog items
Global Const PER_ILAC           As Integer = 6

Global Const PER_MENU_NAME           As String = "MENU" ' DEV_STRING
Global Const PER_DIAGRAM_NAME        As String = "DIAGRAM" ' DEV_STRING
Global Const PER_SYMBOL_NAME         As String = "SYMBOL" ' DEV_STRING
                                                ' PLACEHOLDER; there are no symbol permission values per se
Global Const PER_DEFINITION_NAME     As String = "DEFINITION" ' DEV_STRING
Global Const PER_MACRO_NAME          As String = "MACRO" ' DEV_STRING
Global Const PER_CATALOG_NAME        As String = "CATALOG" ' DEV_STRING
 


' Permission Flag Values
' All flag constants need to have a unique value to allow identification of which permission
'type they are associated with
Global Const PERFLAG_INVALID        As Integer = -1
Global Const PERFLAG_NONE           As Integer = 0
Global Const PERFLAG_CREATE         As Integer = 1
Global Const PERFLAG_READ           As Integer = 2
Global Const PERFLAG_WRITE          As Integer = 4
Global Const PERFLAG_DESTROY        As Integer = 8
Global Const PERFLAG_COMPLETE       As Integer = 16
Global Const PERFLAG_VISIBLE        As Integer = 32  ' This item is to be hidden
Global Const PERFLAG_ENABLED        As Integer = 64  ' This item is to be disabled
Global Const PERFLAG_EXECUTABLE     As Integer = 128
Global Const PERFLAG_DEPENDENTDEFS  As Integer = 256
Global Const PERFLAG_OVERRIDE       As Integer = 512 ' Means that inherit/disinherit will not change the entire permission value

Global Const PERFLAG_CREATE_NAME        As String = "CREATE" ' DEV_STRING
Global Const PERFLAG_READ_NAME          As String = "READ" ' DEV_STRING
Global Const PERFLAG_WRITE_NAME         As String = "WRITE" ' DEV_STRING
Global Const PERFLAG_DESTROY_NAME       As String = "DESTROY" ' DEV_STRING
Global Const PERFLAG_COMPLETE_NAME      As String = "COMPLETE" ' DEV_STRING
Global Const PERFLAG_VISIBLE_NAME       As String = "VISIBLE" ' DEV_STRING
Global Const PERFLAG_ENABLED_NAME       As String = "ENABLED" ' DEV_STRING
Global Const PERFLAG_EXECUTABLE_NAME    As String = "EXECUTABLE" ' DEV_STRING
Global Const PERFLAG_DEPENDENTDEFS_NAME As String = "DEPENDENT DEFINITIONS" ' DEV_STRING
Global Const PERFLAG_OVERRIDE_NAME      As String = "OVERRIDE" ' DEV_STRING

' Permission types and associated values

' PER_CATALOG (FLAGS)
'PERFLAG_CREATE
'PERFLAG_READ
'PERFLAG_WRITE
'PERFLAG_DESTROY
'PERFLAG_CREATE_NAME
'PERFLAG_READ_NAME
'PERFLAG_WRITE_NAME
'PERFLAG_DESTROY_NAME
 
' PER_DEFINITION
'PERFLAG_READ
'PERFLAG_WRITE
'PERFLAG_OVERRIDE
'PERFLAG_READ_NAME
'PERFLAG_WRITE_NAME
'PERFLAG_OVERRIDE_NAME
 
' PER_DIAGRAM
'PERFLAG_READ
'PERFLAG_WRITE
'PERFLAG_OVERRIDE
'PERFLAG_READ_NAME
'PERFLAG_WRITE_NAME
'PERFLAG_OVERRIDE_NAME
 
' PER_MACRO
'PERFLAG_EXECUTABLE
'PERFLAG_OVERRIDE

' PER_MENU
'PERFLAG_VISIBLE
'PERFLAG_ENABLED
'PERFLAG_OVERRIDE
'PERFLAG_VISIBLE_NAME
'PERFLAG_ENABLED_NAME
'PERFLAG_OVERRIDE_NAME

' PER_SYMBOL
    ' PLACEHOLDER; there are no symbol permission values per se
 
' PER_CATALOG (PERMISSION IDS)
Global Const PERID_CATALOGPERMISSION As String = "CATALOG" ' DEV_STRING

' Permission error types
Global Const PER_ERR_SUCCESS    As Integer = 0  ' Success
Global Const PER_ERR_NOSUCHTYPE As Integer = 1  ' The type specified was not in the acceptable range of known types
Global Const PER_ERR_NOTFOUND   As Integer = 2  ' No permission with the ID given was found in that type
 
' Enterprise Manager Object Model Errors
Global Const emErrorBase As Long = 1000
Global Const EM_ERR_GENERALERROR As Long = vbObjectError + emErrorBase + 1
Global Const EM_ERR_ACCESSCATALOG As Long = vbObjectError + emErrorBase + 2
Global Const EM_ERR_READCATALOG As Long = vbObjectError + emErrorBase + 3
Global Const EM_ERR_ACCESSINGCOLLECTION As Long = vbObjectError + emErrorBase + 4
Global Const EM_ERR_CONNECT As Long = vbObjectError + emErrorBase + 5
Global Const EM_ERR_LOGIN As Long = vbObjectError + emErrorBase + 6
Global Const EM_ERR_READROLES As Long = vbObjectError + emErrorBase + 7
Global Const EM_ERR_READENCYS As Long = vbObjectError + emErrorBase + 8
Global Const EM_ERR_READPERMS As Long = vbObjectError + emErrorBase + 9
Global Const EM_ERR_ATTACH As Long = vbObjectError + emErrorBase + 10
Global Const EM_ERR_ATTACH_NOUSER As Long = vbObjectError + emErrorBase + 11
Global Const EM_ERR_ATTACH_EXISTS As Long = vbObjectError + emErrorBase + 12
Global Const EM_ERR_ATTACH_BADSERVER As Long = vbObjectError + emErrorBase + 13
Global Const EM_ERR_ATTACH_NOPERMISSION As Long = vbObjectError + emErrorBase + 14
Global Const EM_ERR_ATTACH_CANTGETENCYID As Long = vbObjectError + emErrorBase + 15
Global Const EM_ERR_ATTACH_NOEXISTS As Long = vbObjectError + emErrorBase + 16
Global Const EM_ERR_ATTACH_CANTCHANGEENCYSTATUS As Long = vbObjectError + emErrorBase + 17
Global Const EM_ERR_ATTACH_LAST As Long = vbObjectError + emErrorBase + 17  ' Same as last ATTACH error code
Global Const EM_ERR_CANCELLED As Long = vbObjectError + emErrorBase + 18
Global Const EM_ERR_WARNINGS As Long = vbObjectError + emErrorBase + 19
Global Const EM_ERR_ITEM_ALREADY_EXISTS_IN_COLLECTION As Long = vbObjectError + emErrorBase + 20
Global Const EM_ERR_FAILED_TO_UPDATE_SALIBNET_VIEWS As Long = vbObjectError + emErrorBase + 21
Global Const EM_ERR_PARAMETER_ERROR As Long = vbObjectError + emErrorBase + 22
Global Const EM_ERR_FAILED_TO_DELETE_ALL_PERMISSIONS As Long = vbObjectError + emErrorBase + 23

Global Const EM_ERR_READGROUPS As Long = vbObjectError + emErrorBase + 50
Global Const EM_ERR_READGROUP As Long = vbObjectError + emErrorBase + 51
Global Const EM_ERR_READUSERS As Long = vbObjectError + emErrorBase + 52
Global Const EM_ERR_READUSER As Long = vbObjectError + emErrorBase + 53
Global Const EM_ERR_READPERMISSIONS As Long = vbObjectError + emErrorBase + 54
Global Const EM_ERR_FAILEDTOUPGRADECATALOG As Long = vbObjectError + emErrorBase + 55

' errors for sql permission assignment
Global Const EM_ERR_RevokingPermissionsFailure As Long = vbObjectError + emErrorBase + 99
Global Const EM_ERR_AssigningPermissionsFailure As Long = vbObjectError + emErrorBase + 100
Global Const EM_ERR_FailedToCreateUserLogin As Long = vbObjectError + emErrorBase + 101
Global Const EM_ERR_FailedToCreateDatabaseRole As Long = vbObjectError + emErrorBase + 102
Global Const EM_ERR_FailedToCreateAccessControlAdminRole As Long = vbObjectError + emErrorBase + 103
Global Const EM_ERR_FailedToAssignMasterPrivilegesToAccessControlAdministrationRole As Long = vbObjectError + emErrorBase + 104
Global Const EM_ERR_FailedToCreateAccessControlAdminRoleInDB As Long = vbObjectError + emErrorBase + 105
Global Const EM_ERR_FailedToAssignDBAccessAdminPrivilegesInCatalog As Long = vbObjectError + emErrorBase + 106
Global Const EM_ERR_FailedToCatalogAssignPrivilegesToAccessControlAdministrationRole As Long = vbObjectError + emErrorBase + 107
Global Const EM_ERR_FailedToCreateAccessControlEncyclopediaUserRole As Long = vbObjectError + emErrorBase + 108
Global Const EM_ERR_FailedToAssignPrivilegesToAccessCotnrolEncyUserRole As Long = vbObjectError + emErrorBase + 109
Global Const EM_ERR_FailedToCreateAccessControlCatalogUserRole As Long = vbObjectError + emErrorBase + 110
Global Const EM_ERR_FailedToAssignPrivilegesToAccessControlCatalogUserRole As Long = vbObjectError + emErrorBase + 111
Global Const EM_ERR_FailedToOpenMasterDatabase As Long = vbObjectError + emErrorBase + 112
Global Const EM_ERR_FailedToCreateAccessControlAdminRoleForUser As Long = vbObjectError + emErrorBase + 113
Global Const EM_ERR_FailedToAddUserToMasterDB As Long = vbObjectError + emErrorBase + 114
Global Const EM_ERR_FailedToAssignAccessControlAdministrationRoleToUser As Long = vbObjectError + emErrorBase + 115
Global Const EM_ERR_FailedToOpenDatabase As Long = vbObjectError + emErrorBase + 116
Global Const EM_ERR_FailedToCreateAccessControlAdministrationRoleForUser As Long = vbObjectError + emErrorBase + 117
Global Const EM_ERR_FailedToAddUserToCatalog As Long = vbObjectError + emErrorBase + 118
Global Const EM_ERR_FailedToAssignAccessControlAdministrationRoleToUserOnCatalog As Long = vbObjectError + emErrorBase + 119
Global Const EM_ERR_FailedToOpenCatalog As Long = vbObjectError + emErrorBase + 120
Global Const EM_ERR_FailedToCreateAccessControlUserRoleOnCatalog As Long = vbObjectError + emErrorBase + 121
Global Const EM_ERR_FailedToAssignAccessControlRoleToUserOnCatalog As Long = vbObjectError + emErrorBase + 122
Global Const EM_ERR_FailedToOpenEncyclopedia As Long = vbObjectError + emErrorBase + 123
Global Const EM_ERR_FailedToCreateAccessControlUserRoleOnEncy As Long = vbObjectError + emErrorBase + 124
Global Const EM_ERR_FailedToAddUserToEncyclopedia As Long = vbObjectError + emErrorBase + 125
Global Const EM_ERR_FailedToAssignAccessControlUserRoleOnEncy As Long = vbObjectError + emErrorBase + 126
Global Const EM_ERR_FailedToAssignSecurityAdminToAccessControlAdministrationRole As Long = vbObjectError + emErrorBase + 127
Global Const EM_ERR_FailedToAssignSecurityAdminRolToUser As Long = vbObjectError + emErrorBase + 128
Global Const EM_ERR_FailedToDropAccessControlAdministrationRoleFromUser As Long = vbObjectError + emErrorBase + 129
Global Const EM_ERR_FailedToDropSecurityAdminRolFromUser As Long = vbObjectError + emErrorBase + 130
Global Const EM_ERR_FailedToDropUserFromCatalog As Long = vbObjectError + emErrorBase + 131
Global Const EM_ERR_FailedToDropUserFromMasterDB As Long = vbObjectError + emErrorBase + 132
Global Const EM_ERR_FailedToDropAccessControlAdministrationRoleFromUserOnCatalog As Long = vbObjectError + emErrorBase + 133
Global Const EM_ERR_FailedToDropAccessControlRoleFromUserOnCatalog As Long = vbObjectError + emErrorBase + 134
Global Const EM_ERR_FailedToDropUserFromEncyclopedia As Long = vbObjectError + emErrorBase + 135
Global Const EM_ERR_FailedToDropPrivilegesAccessControlUserRoleOnEncy As Long = vbObjectError + emErrorBase + 136

Global Const EM_ERR_CatalogVersionMoreRecentThanProductVersion As Long = vbObjectError + emErrorBase + 137

' errors for sql permission assignment
Global Const EM_ERR_FailedToDestroyDatabaseRole As Long = vbObjectError + emErrorBase + 138
Global Const EM_ERR_FailedToAssignPrivilegesToAccessControlEncyUserRole As Long = vbObjectError + emErrorBase + 139
Global Const EM_ERR_FailedToDestroyAccessControlAdminRoleForUser As Long = vbObjectError + emErrorBase + 140
Global Const EM_ERR_FailedToDestroyAccessControlAdministrationRoleForUser As Long = vbObjectError + emErrorBase + 141
Global Const EM_ERR_FailedToDestroyAccessControlUserRoleOnCatalog As Long = vbObjectError + emErrorBase + 142

Global Const EM_ERR_CatalogNeedsUpgrading As Long = vbObjectError + emErrorBase + 143

' Other Permission constants
Global Const MAXPERMISSIONNAME  As Integer = 255




' Aggregation Types
Global Const MAXAGGREGATIONTYPES    As Integer = 2
 
Global Const AGG_INHERIT            As Integer = 0
Global Const AGG_DISINHERIT         As Integer = 1
Global Const AGG_INHERIT_NAME       As String = "INHERIT" ' DEV_STRING
Global Const AGG_DISINHERIT_NAME    As String = "DISINHERIT" ' DEV_STRING
 
' Other Aggregation constants
Global Const MAXAGGREGATIONNAME     As Integer = 255




' User IDs
Global Const USERID_EVERYONEGROUP_NUMBER        As Long = 1

' Other User Constants
Global Const MAXUSERNAME                        As Integer = 255




' Role IDs
Global Const ROLEID_ADMINISTRATORNUMBER As Integer = 1

' Other Role Constants
Global Const MAXROLENAME                As Integer = 255





' Binary and Triplet Item, Filter and Remove functions in place of the name of an
'individual key when we don't care what that key value is
Public Const STR_WILDCARD   As String = "*" ' DEV_STRING

' Constants that can be used in place of a sequence number when
'sequencing role aggregations
Public Const SEQ_FIRST      As Long = 1
Public Const SEQ_LAST       As Long = -1

' Progress constant used when subtask has been completed
Public Const PRG_DONE       As String = "Done" ' DEV_STRING



Public Const USER_IDS_START_HERE    As Integer = 1000



Public Const MAX_AUDITID_LENGTH = 7   ' Keep in synch with MAXAUDITID in design.h

