Link to home
Start Free TrialLog in
Avatar of Sivasan
SivasanFlag for United States of America

asked on

Access form for login using active directory

Hi all,
I have an access application. I have a login form, in MS Access. Currently, I'm saving the user name, password, security level(User,Admin) and their email , in a table 'Table1' in access table. So when the user opens the login form, he/she enters the user name and password and from that form on clicking the submit button, I authenticate against 'Table1' and redirect to other form, by carrying their name and displaying it on other forms.
Now, I like to get the user name from the domain login ( active directory) on their computer so they don't have to have a separate password for this app and keep entering everytime.

Ideally, when they click Login form I automatically capture their login name from their domain login into the computer and using the 'table1' in access, I can find the security level and direct to other forms, I also like to capture their email from active directory if possible.
I will appreciate if somebody can tell me how I can do that.
Thank you in advance.
ASKER CERTIFIED SOLUTION
Avatar of als315
als315
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sivasan

ASKER

Hi Als315,
Thanks you.Does this go on on click event of a button?
I tried to put the code you have provided on a on click event of a button, to see if I can get the user name.It says expected End of Sub.When I add End Sub, it still says End Sub expected.
At least to test, I'm trying to pass the user name from your code to a text box Tbox in my form on a click of event of a button. I would appreciate if you can tell me what I'm missing.
Thanks
It is function, place it to module. In onclick event you can use it as follows:
Dim mail as string
mail = get_mail
Avatar of Sivasan

ASKER

Hi Als315,
Thanks a millione. Yes, when I did mail = get_mail, now, I can get the email. I'm trying to get the user name as well.Looking at your code, I thought UserName will contain the user name but doesn't display the name.I tried the following.

Private Sub Command0_Click()
Dim mail As String
Dim uname As String
mail = get_mail
uname = UserName
Me.T1 = mail
Me.T2 = uname

End Sub

Wondering if I'm doing it right.
Thanks
uname =  environ("username")
Avatar of Sivasan

ASKER

Thanks a million for your help