Using Windows Authentication

  • Thread starter Thread starter Ryan Langton
  • Start date Start date
R

Ryan Langton

For all of my previous Access .ADP applications, I've used a login screen
that the user uses to authenticate (a table stores usernames/passwords).
Once they've logged in, I store their login information in global variables.
The problem I've found is that sometimes when the programs are left up for
some time, the global variable information is dropped. They'll try to
access some portion of my program and they'll have to go back to the login
screen to re-authenticate.

Since the SQL Server already uses Windows authentication, is there anyway to
use this as their login info for my program as well? So instead of checking
some global variable, whenever they try to access a portion of the program
(a form or something) I can check their permissions based on their windows
authentication?

Thanks,
Ryan
 
Ryan Langton said:
Since the SQL Server already uses Windows authentication, is there anyway to
use this as their login info for my program as well?

Yes there is. I highly recommend to do this instead using
global variables.

You can query the SQL-Server for the loginname of the current
user by this SQL: SELECT SUser_SName()
If you use that to open a recordset, the only field will contain
the login name.

Cheers
Phil
 
That's awesome Philipp. Now I have my work cut out for me going back to
reprogram all my older apps to do this.

While I'm at it, is there a way to query the database for all current
allowed logins? I want to give admins access to change certain permissions
for users (not SQL permissions, but program-specific permissions which I
will store in a permissions table).

Thanks!
Ryan
 
Back
Top