简体   繁体   中英

Automatically authenticating a user in java or .net app using active directory

In a .net and java application (i mean i have 2 twin apps written in both technologies) I would like to peroform autologin using AD/LDAP. The flow is:

0) user MyDomain\\john logged in in an Windows machine in the MyDomain domain

1) app URL is browsed

2) The app checks whether MyDomain\\john is an AD user correctly logged in

3) if the user is logged in correctly i check in the App DB to see if the MyDomain\\john is mapped in the users table

4) if match is found login is possible, login screen is bypassed and user is authenticated in the app

in principle all i need is to know which is the currently correctly loged in AD user, could you please suggest which .net and java function is needed to perform such check?

Thanks a lot.

I am not clear on a few aspects of your question but maybe this will help.

Java

String username = System.getProperty("user.name");

.NET (C#)

Console.WriteLine("UserName: {0}", Environment.UserName);

Not sure what a "AD user correctly logged in" and "if the user is logged in correctly" means.

IMHO, you are not performing any Authentication and only reading an environment variable that MAY NOT be set by the "system"

You should extract the authentication to an OpenID Connect product or library to frontend this type of Authentication and let that service perform "real" Authentication check.

And you should Tell us what you have tried and show logs or results and Read: https://stackoverflow.com/help/how-to-ask

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM