CAS 单点登录,通过ticket 获取登录用户

                    string url =SSOValidate+"?service=" + WebValidate + "&ticket=" + Ticket + "&pgtUrl" +    WebValidate + "?proxyResponse=true";
                    string clearPassResponse = Utils.GetHttpWebResponse(url, "", Encoding.UTF8);//POST获取返回 登陆用户信息
                    using (TextReader stringReader = new StringReader(clearPassResponse))
                    {
                        XmlReaderSettings xmlReaderSetting = new XmlReaderSettings();
                        xmlReaderSetting.ConformanceLevel = ConformanceLevel.Auto;
                        xmlReaderSetting.IgnoreWhitespace = true;
                        using (XmlReader xmlReader = XmlReader.Create(stringReader, xmlReaderSetting))
                        {
                            if (xmlReader.ReadToFollowing("cas:username"))
                            {
                                string username = xmlReader.ReadElementString();
                                if (String.IsNullOrEmpty(username))
                                {
                                    throw new HttpException("登陆失败!");
                                }
                                LoginUtil.SetLogin(username);
                            }
                        }
                    }

 

 



posted @ 2016-04-12 09:14  时光吹老了好少年  阅读(9170)  评论(0编辑  收藏  举报