The example in this article describes the asp.net simple implementation of single sign-on (SSO) method. Share to everyone for your reference, specific as follows:
Single sign-on (Sign on, SSO) is one of the more popular solutions for enterprise business integration, and SSO enables users to access all trusted applications with only one login at a time in multiple application systems
CAS (central authentication Service) is a good single sign-on framework for WEB applications (developed by Yale University) that is mainly used in Java PHP and you can study it.
Here's a simple way to implement a single sign-on:
public void Singleuserlogin (string userName) {
//define key value
string key=username;
String value=convert.tostring (Cache[key]);
if (value==null| | Value==string. Empty) {
//define cache Expiration Time
TimeSpan span=new TimeSpan (0,0,httpcontext.current.session.timeout,0,0); Insert a user-related Cache value on the first landing,
HttpContext.Current.Cache.Insert (Key,key,null,datetime.maxvalue,span, System.web.caching.cacheitempriority.notremovable,null);
session["UserName"]=username;
Response.Redirect ("main.aspx");
}
else if (Cache[key). ToString () ==key) {
//Repeat login Response.Write ("<mce:script type= text/javascript" ><!-- alert (' Your account has landed! '); window.location= ' login.aspx '; --></mce:script> ");
}
else{
//Cancel current session Sessions
Session.Abandon ();
}
Configure form mode in Web Config
<authentication mode= the "forms" >//mode value is forms for defining form validation
<forms loginurl= "mananger/login.aspx". Aspxauth ">//users visit mananger/login.aspx page
</forms>
</authentication>
< without landing authorization>
<deny users= "?" />
</authorization>
I hope this article will help you to ASP.net program design.