MOSS2010中使用SSO来做单点登录,如何以管理的身份,根据appId和指定一个域账号,去取出该账号所设置的业务系统的登录和密码????
没完全明白
1,sso 你已经配置好了,就缺获取的密码和用户名的方法?
下面代码修改一下,就可以,
原文地址:http://www.ibeifeng.com/tech.php?id=60015
protectedvoid Button1_Click(object sender, EventArgs e)
{
string m_userName =string.Empty;
string m_password =string.Empty;
string m_html =string.Empty;
string m_appId ="163Mail";
SecureStoreProvider m_provider =new SecureStoreProvider();
SPSite m_site = SPContext.Current.Site;
SPServiceContext m_serviceContext = SPServiceContext.GetContext(m_site);
m_provider.Context = m_serviceContext;
try
{
SecureStoreCredentialCollection m_sscc = m_provider.GetCredentials(m_appId);
foreach (SecureStoreCredential ssc in m_sscc)
{
switch (ssc.CredentialType)
{
case SecureStoreCredentialType.Generic:
break;
case SecureStoreCredentialType.Key:
break;
case SecureStoreCredentialType.Password:
m_password = ToClrString(ssc.Credential);
break;
case SecureStoreCredentialType.Pin:
break;
case SecureStoreCredentialType.UserName:
m_userName = ToClrString(ssc.Credential);
break;
case SecureStoreCredentialType.WindowsPassword:
break;
case SecureStoreCredentialType.WindowsUserName:
break;
default:
break;
}
}
m_html +="<script>";
m_html +=string.Format("window.location.href='http://reg.163.com/login.jsp?url=&type=1&product=&savelogin=&outfoxer=&domains=&syscheckcode=4ecd8fe3803494cff0df5414f321fd5f9afa4c78&username={0}%40163.com&password={1}&Submit='", m_userName, m_password);
m_html +="</script>";
Response.Write(m_html);
}
catch (Exception ex)
{
Response.Write("<script>window.location.href= '/_layouts/SecureStoreSetCredentials.aspx?TargetAppId="+ m_appId +"';</script>");
}
}