KerryS1
asked on
Access 2010 and User Level Security to SQL back-end
I'm designing an Access 2010 front-end application that hooks to an SQL Express backend. The organization that I am designing this for does not want to manage separate logon ids and security levels within Access. They would prefer to set up Roles and Users within SQL and use Windows Authentication for the connection. Here's the question, is it possible through ADOX or some other library to obtain the current user's credentials upon the start-up of the front-end. Depending on who the user is and their role, the start-up module of the application (through VBA) will determine what portions of the application are available for that use (i.e. Menus and Menu options).
ASKER
Actually what I need is to determine which Group (Role) on the SQL Server that the current user belongs to aka Readers, Writers, Admin, etc.
This might help:
Function GetSqlUser() As String
Dim qrd As DAO.QueryDef
Dim rst As DAO.Recordset
Set qrd = CurrentDb.CreateQueryDef("")
With qrd
.Connect = CurrentDb.TableDefs(0).Connect
.SQL = "SELECT SYSTEM_USER"
.ReturnsRecords = True
End With
Set rst = qrd.OpenRecordset()
GetSqlUser = rst(0).Value
rst.Close
Set rst = Nothing
Set qrd = Nothing
End Function
ASKER
That code will return the ServerName\User but unfortunately it doesn't return what I need. This application is not allowed to contain individual user IDs so just returning the user name won't help in determining the user's role and security priviledges on the SQL server. What I need is to determine what priviledges the current user has access to. One option would be to do a test update on a table where only admins have full rights. If the update fails then I know the current user does not have admin priviledges. I was hoping there would be a simpler solution other than testing for error codes. For example, ADOX has a GetPermissions method. Does anyone know of a way to use the above suggested code that returns a user name in combination with the GetPermissions method to return that user's permissions? I could then test for adRightNone or adRightFull to determine which menus to display.
ASKER
SELECT * FROM fn_mypermissions('lkpLoanT ype','obje ct')
Returns permission_name and subentity_name but no User name.
Returns permission_name and subentity_name but no User name.
AFAIK, you have to use both of them together. One for the user and the other to get that user's permissions.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Problem not solved.
I would recommend that you request the question be reopened.
Get Login name