这是提供的index.aspx代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD><Script Language="VB" Runat="Server">
Function getCookie()
Dim cookieValue
CookieValue=""
IF not ( Request.Cookies("iPlanetDirectoryPro") is nothing ) THEN
  CookieValue = Request.Cookies("iPlanetDirectoryPro").value
end if
Return cookieValue 
End Function
</Script>
<BODY><center><%
Dim login,gotoURL,serverUrl,loginUrl,logout,logoutUrl
Dim idstar
idstar = Server.CreateObject("Idstar.IdentityManager")
login = idstar.GetLoginURL()
logout = idstar.GetLogoutURL()
serverUrl = "http://cxiao.wiscom.com.cn"
gotoUrl = serverUrl & Request.RawUrl
loginUrl = login & "?goto=" & Server.UrlEncode(gotoUrl)
logoutUrl = logout & "?goto=" & Server.UrlEncode(gotoUrl) Dim cookieValue
Dim currentUser cookieValue = getCookie()
currentUser = ""
currentUser = idstar.GetCurrentUser( "" & Server.UrlDecode(cookieValue) )

If ( Len(currentUser) <> 0 ) Then
Response.Write( "cookies值是:" & Server.UrlDecode(cookieValue))
Response.Write("<p>已登录")
%>
<p>当前用户: <%= currentUser %>
<p><a href="search.aspx">属性查询</a>
<p><a href="<%= logoutUrl %>">注销</a>
<%
Else
%>
<p>您没有登录,请登录  <a href="<%= loginUrl %>">Login</a>
<%
End If

%>
</center>
</BODY>
</HTML>
------------------
我用的是C# ASP.NET。麻烦各位看下上述用例,怎么转换到我的登录首页login.aspx实现单点登录
    protected void Page_Load(object sender, EventArgs e)
    {          if (Request.QueryString["roleid"] != null && Request.QueryString["accid"] != null && Request.QueryString["tim"] != null && Request.QueryString["crypt"] != null)
        {
            
            Session["roleid"] = Request.QueryString["roleid"].ToString();
            Session["sno"] = Request.QueryString["accid"].ToString();
      
 
       
      
            Response.Write(SysOperation.OpenDialog(
              sno));//test show            Student_Teacher_Login(sno);
        }
            
        else
        {
            Response.Write(SysOperation.OpenDialog(
                "无法获取URL参数,请检查登录..."));
            Response.Write("<script>history.back()</script>");
            return;
        }
    }

解决方案 »

  1.   

    示例给的是VB.NET,不太了解
    想问下我在Page_Load中怎么实现获取COOKIES值、当前登录用户名
      

  2.   

    读cookieif(Request.Cookies["iPlanetDirectoryPro"]!=null)   
    {   
    //Request.Cookies["iPlanetDirectoryPro"].Value 就是了
    }
    当前登录用户名 ,在你的示例中 是有个方法根据cookie值查出来的
      

  3.   


        HttpCookie cookieValue;
        string currentUser;    public object getCookie()
        {
            //HttpCookie cookieValue = new HttpCookie("iPlanetDirectoryPro");
            cookieValue = HttpContext.Current.Request.Cookies["iPlanetDirectoryPro"];        if (cookieValue != null)
                return cookieValue.Value;  
            else  
                return null;
         
        }    protected void Page_Load(object sender, EventArgs e)
        {        object idstar = Server.CreateObject("Idstar.IdentityManager");        getCookie();
            string currentUser = idstar.GetCurrentUser["" + Server.UrlDecode(cookieValue)]; 
            
            if (Request.Cookies["iPlanetDirectoryPro"] != null) 
            {            sno = currentUser.ToString();
          
                Response.Write(SysOperation.OpenDialog(
                  sno));//test show            Student_Teacher_Login(sno);
            }
                
            else
            {
                Response.Write(SysOperation.OpenDialog(
                    "无法获取URL参数,请检查登录..."));
                Response.Write("<script>history.back()</script>");
                return;
            }
        }错误提示:错误 1 “object”不包含“GetCurrentUser”的定义,并且找不到可接受类型为“object”的第一个参数的扩展方法“GetCurrentUser”(是否缺少 using 指令或程序集引用?)
    错误 2 与“System.Web.HttpServerUtility.UrlDecode(string)”最匹配的重载方法具有一些无效参数
    错误 3 参数“1”: 无法从“System.Web.HttpCookie”转换为“string”这里idstar.GetCurrentUser是参考接口( vb.net )提供的代码
      

  4.   

    object idstar = Server.CreateObject("Idstar.IdentityManager");不能这么写的,在你之前的示例中  Idstar.IdentityManager 应该是个自定义的组件你查看它是怎样实现的,然后用C# 重写一下
      

  5.   


    =====================
    Idstar2 Win32 接口说明Idstar2 Win32的接口使用 Com对象,使用前需要
     (1) 将“IDStarV3.0认证接口\ICEClient\Win32\COM”下所有的.Dll文件拷贝到客户端应用所在服务器中的某一个目录下,建议目录名称为英文且全路径无空格。
     (2) 修改组件所在文件夹下的client.properties 文件,按照部署Java客户端的方法修改其中的参数。
     (3) 运行组件目录下的Reqiste或者直接输入命令regsvr32 idstar.dll进行注册。可以使用UnRegiste脚本进行反注册。【注意】
    (1) 当com组件应用在IIS服务器上的asp或者asp.net的时候,如果重新启动了Server端或者修改了Client端的配置,都要重新启动IIS服务器。
    (2) 必须先修改client.properties再注册组件,修改该文件后需要重新注册
    ASP和Php都调用 Com对象Com对象接口说明:
    ProgID :  Idstar.IdentityManager
    接口:
    String GetUserNameByID(String UserID) 取用户姓名, 
    参数:UserID——登录名
    返回:用户姓名Variant GetUserAttribute(String UserID, String AttrName) 取用户的属性
    参数: UserID——登录名  
    AttrName —— 属性名
    返回:
    Vaiant 数组,属性存在多值,Variant GetUserGroup(String UserID) 取用户组....============================
    接口说明中提到ProgID是 Idstar.IdentityManager