1、官方下载.net 客户端dll
在工程中加载dll
webconfig中配置
<configSections>
<sectionname="casClientConfig"type="DotNetCasClient.Configuration.CasClientConfiguration, DotNetCasClient"/>
</configSections>
<casClientConfig
//cas服务端登录页面
casServerLoginUrl="http://192.168.12.196/cas/login"
//cas服务端验证
casServerUrlPrefix="http://192.168.12.196/cas"
//跳转的页面,只取到http://localhost:3273/
serverName="http://localhost:3273/ExampleWebSite"
notAuthorizedUrl="~/NotAuthorized.aspx"
cookiesRequiredUrl="~/CookiesRequired.aspx"
redirectAfterValidation="true"
gateway="false"
renew="false"
singleSignOut="true"
ticketTimeTolerance="5000"
ticketValidatorName="Cas20"
serviceTicketManager="CacheServiceTicketManager"
gatewayStatusCookieName="CasGatewayStatus" />
<system.web>
.net 自己的Forms认证这的配置也很重要,
<authenticationmode="Forms">
<forms
loginUrl="http://192.168.12.196/cas/login"
timeout="30"
defaultUrl="~/Default.aspx"
cookieless="UseCookies"
slidingExpiration="true"
//发布到外网的话path="/"
path="/ExampleWebSite/"
/>
</authentication>
<authorization>
<denyusers="?"/>
<allowusers="*"/>
</authorization
最后就是httpModel的配置了
<httpModules>
<addname="DotNetCasClient"type="DotNetCasClient.CasAuthenticationModule,DotNetCasClient"/>
</httpModules>
//跳回的地址=serverName+path+"跳转前的页面"
//跳回页面取数据方法
using DotNetCasClient;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
getUserInfo();
}
private void getUserInfo()
{
if (CasAuthentication.ServiceTicketManager != null)
{
HttpCookie ticketCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
if (ticketCookie != null)
{
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(ticketCookie.Value);
if (ticket != null)
{
CasAuthenticationTicket casTicket = CasAuthentication.ServiceTicketManager.GetTicket(ticket.UserData);
if (casTicket != null)
{
TextBox1.Text = casTicket.NetId;
TextBox2.Text = casTicket.Assertion.PrincipalName;
}
}
}
}
}
}
//单点退出
修改DotNetCasClient.cs页面
public static void SingleSignOut()
{
Initialize();
HttpContext context = HttpContext.Current;
HttpResponse response = context.Response;
// Necessary for ASP.NET MVC Support.
if (context.User.Identity.IsAuthenticated)
{
ClearAuthCookie();
//update by songjg logout into login
//注销页面
//string singleSignOutRedirectUrl = UrlUtil.ConstructSingleSignOutRedirectUrl();
//修改重定向到login页面
string strLoginUrl = CasClientConfig.CasServerLoginUrl;
// Leave endResponse as true. This will throw a handled ThreadAbortException
// but it is necessary to support SingleSignOut in ASP.NET MVC applications.
response.Redirect(strLoginUrl, true);
//update by songjg logout into login
}
}
生成新的动态库DotNetCasClient.dll
web.config
去掉重定向配置
notAuthorizedUrl="~/NotAuthorized.aspx" 改为
notAuthorizedUrl=""
不改会发生重定向退出事件
protected void LinkButton1_Click(object sender, EventArgs e)
{
Session.Clear();
CasAuthentication.SingleSignOut();
}
2、服务端的源码中AssemblyInfo.cs.tmpl文件去掉.tmpl 编译动态库工程。工程就能运行起来
另一种办法,不用重编译代码,只要修改相应文件就能满足退出到登录页面
配置PHP CLIENT6. 如何实现单点注销
注销通过转到http://hostname:port/cas/logout时,注销成功后,转到成功提示页面。如果需要指定注销成功后的页面,有两点要做:
1、 打开tomcat6.0\cas\WEB-INF\cas-server.xml,找到下面代码:
<bean id="logoutController" class="org.jasig.cas.web.LogoutController"
p:centralAuthenticationService-ref="centralAuthenticationService"
p:logoutView="casLogoutView"
p:warnCookieGenerator-ref="warnCookieGenerator"
p:ticketGrantingTicketCookieGenerator-ref="ticketGrantingTicketCookieGenerator"
/>
加入p:followServiceRedirects ="True"参数。
2、修改注销按钮的跳转页面:
http://hostname:port/cas/logout?service=http://what-you-want-to
http://hi.baidu.com/spanlessbug/item/1d5ff3cad25bf5d6964452b5
cas response.spush() 有关 去掉这句cas就正常了。待验证?
相关推荐
c#Socket客户端断线重连! c#Socket客户端断线重连! c#Socket客户端断线重连! c#Socket客户端断线重连!
C#winfrom客户端浏览器,本人亲测试,可以使用,方便,可以查找历史记录
C# Netty 客户端,服务器端 自己研究一才研究出来的与大家分享一下
C#WebSocket客户端及服务端Demo,服务端采用SocketTCP通讯,WebSocket通讯与传统通讯的差异就是多了一些消息解析,详情见服务端源代码!
c#Socket客户端断线重连封装类(可直接调用).rar
c# 邮件客户端Email_Client
C#Socket客户端.zip
wcf c# 服务器 客户端 示例 wcf c# 服务器 客户端 示例
客户端计算1+1 传递给服务器 通过服务器运算 把2返回给客户端
文档内有客户端和服务端socket,实际项目中只用到了客户端,会比较详细,支持断开重连
C# TCP 客户端源码实现。
很实用,对于单片机类产品收发很直接,C#TCP客户端,只发16进制,网上流传的TPC,收16进制的时候都会有一堆0,这个代码是没有用,因目前用不到报务端就没写,以后用到再上传
该源码经过整理,整合形成一个完整的C#版本MQTT协议版本的工具,可以直接加入项目类库,添加引用后既可使用.
利用C#编写MQTT客户端上位机,简单实用,自带MQTT使用库
基于VS2019,使用WinForm作为WebSocket客户端,连接WebSocket服务器并进行数据通信。
实现Java服务端和C#客户端联通 Java使用Netty 开发环境为IDEA C#使用DotNetty 开发环境为VS2017 运行时先开启Java服务端 再开启客户端
客户端ip 客户端主机名 客户端浏览器IE 客户端浏览器 版本号 客户端操作系统 服务器ip 服务器名
C# FTP 客户端, FTP 文件传输,VS2008 实现 FTP 文件传输。
C#编写的邮件客户端,access数据库存储
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Net; using System.Net.Sockets;... }