What happened? Since when is the IsInGroup function case- sensitive?
Here's the function:
''''''''''''''''''''
Public Function IsInGroup(UsrName As String, GrpName As String) As Boolean
'Determines whether UsrName is a member of GrpName
Dim grp As Group
Dim IIG As Boolean
Dim usr As User
IIG = False
For Each usr In DBEngine.Workspaces(0).Users
If usr.Name = UsrName Then GoTo FoundUser
Next
GoTo IIG_Exit
FoundUser:
For Each grp In usr.Groups
If grp.Name = GrpName Then IIG = True
Next
IIG_Exit:
IsInGroup = IIG
End Function
''''''''''''''''''''
The "If usr.Name = UsrName" is case-sensitive; so, for instance, if you log in as "mgr" but the login was originally created as "Mgr," instead usr.Name being recognized as equal to UsrName, it goes unrecognized. This is inconsistent with the case-insensitivity of the user name for login purposes.
Also, if you attempt to use the function in a sub, e.g., "If IsInGroup(CurrentUser, "admins") = True," it doesn't return true unless you use a case-sensitive rendition of the group name, i.e., "If IsInGroup(CurrentUser, "Admins")."
Can this all be rendered case-insensitive? Thanks in advance if anyone knows the answer or has a solution.
Here's the function:
''''''''''''''''''''
Public Function IsInGroup(UsrName As String, GrpName As String) As Boolean
'Determines whether UsrName is a member of GrpName
Dim grp As Group
Dim IIG As Boolean
Dim usr As User
IIG = False
For Each usr In DBEngine.Workspaces(0).Users
If usr.Name = UsrName Then GoTo FoundUser
Next
GoTo IIG_Exit
FoundUser:
For Each grp In usr.Groups
If grp.Name = GrpName Then IIG = True
Next
IIG_Exit:
IsInGroup = IIG
End Function
''''''''''''''''''''
The "If usr.Name = UsrName" is case-sensitive; so, for instance, if you log in as "mgr" but the login was originally created as "Mgr," instead usr.Name being recognized as equal to UsrName, it goes unrecognized. This is inconsistent with the case-insensitivity of the user name for login purposes.
Also, if you attempt to use the function in a sub, e.g., "If IsInGroup(CurrentUser, "admins") = True," it doesn't return true unless you use a case-sensitive rendition of the group name, i.e., "If IsInGroup(CurrentUser, "Admins")."
Can this all be rendered case-insensitive? Thanks in advance if anyone knows the answer or has a solution.