Using Windows Authentication

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
 
P

Philipp Stiefel

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
 
R

Ryan Langton

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top