-
Notifications
You must be signed in to change notification settings - Fork 3
/
M_omUserFunctions.def
65 lines (60 loc) · 1.93 KB
/
M_omUserFunctions.def
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Option Compare Database
Option Explicit
Public gUser As New omUser
Public Const UseWindowsAuthentication As Boolean = False
Public Const UseLoginForm As Boolean = True
Public Function GetWindowsUserName() As String
GetWindowsUserName = Environ$("UserName")
End Function
Public Function GetWindowsComputerName() As String
GetWindowsComputerName = Environ$("computername")
End Function
Public Function LoginWithWindowsUser(Optional addWindowsLogon As Boolean = False)
Set gUser = New omUser
gUser.LoginByNameOnly GetWindowsUserName, addWindowsLogon:=True
End Function
Public Function UseWindowsUser()
Set gUser = New omUser
gUser.Name = GetWindowsUserName
End Function
Public Sub UserLock()
If omMSAccessFunctions.FormExists("UserLock") Then
DoCmd.OpenForm "UserLock", , , , acFormReadOnly, acHidden
End If
End Sub
Public Sub AuthenticateUser()
If Not gUser.LoggedIn Then
If UseWindowsAuthentication Then
omUserFunctions.LoginWithWindowsUser True
ElseIf UseLoginForm Then
DoCmd.OpenForm "Login", windowMode:=acDialog
End If
End If
End Sub
Public Sub RecordsetUpdateCreateTracking(rs As ADODB.Recordset, Optional UpdateModify = True)
rs("CreateDate") = Now
On Error Resume Next
omUserFunctions.AuthenticateUser
If gUser.LoggedIn Then
rs("CreateUserName") = gUser.Name
rs("CreateUserId") = gUser.Id
Else
rs("CreateUserName") = gUser.Name
rs("CreateUserId") = gUser.Name
End If
If UpdateModify Then
RecordsetUpdateModifyTracking rs
End If
End Sub
Public Sub RecordsetUpdateModifyTracking(rs As ADODB.Recordset)
rs("ModifyDate") = Now
On Error Resume Next
omUserFunctions.AuthenticateUser
If gUser.LoggedIn Then
rs("ModifyName") = gUser.Name
rs("ModifyUserId") = gUser.Id
Else
rs("ModifyUserName") = gUser.Name
rs("ModifyUserId") = gUser.Name
End If
End Sub