MOSS & SSO 系列2
上回谈到与Exchange Server 2007邮件集成问题,最后有了新版本:
任务当然是从工作流引擎那边抓的,顺便也会用到SSO的,那边是表单验证嘛,这年头用域的不多啊。。。
OWA 2007
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.SharePoint.Portal.SingleSignon;
using Microsoft.SharePoint.Portal;
namespace OWASSOWebPart
{
public class OWASSOWebPart : WebPart
{
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
string strSSOLogonFormUrl = SingleSignonLocator.GetCredentialEntryUrl("OWA");
try
{
writer.Write("If your login fails, please <a href=\"" + strSSOLogonFormUrl + "\">Update your credentials</a> with your new password.<br/>");
string[] rgGetCredentialData = null;
Credentials.GetCredentials(1, "OWA", ref rgGetCredentialData);
string src = "/_layouts/OWARedirect.htm?l=" + rgGetCredentialData[0] + "&p=" + rgGetCredentialData[1];
writer.Write("<iframe frameborder=\"0\" width=\"800\" height=\"600\" src=\"" + src + "\"/>");
}
catch (SingleSignonException ssoe)
{
if (SSOReturnCodes.SSO_E_CREDS_NOT_FOUND == ssoe.LastErrorCode)
{
Context.Response.Redirect(strSSOLogonFormUrl);
}
else
{
writer.Write(ssoe.Message);
}
}
}
}
}
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.SharePoint.Portal.SingleSignon;
using Microsoft.SharePoint.Portal;
namespace OWASSOWebPart
{
public class OWASSOWebPart : WebPart
{
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
string strSSOLogonFormUrl = SingleSignonLocator.GetCredentialEntryUrl("OWA");
try
{
writer.Write("If your login fails, please <a href=\"" + strSSOLogonFormUrl + "\">Update your credentials</a> with your new password.<br/>");
string[] rgGetCredentialData = null;
Credentials.GetCredentials(1, "OWA", ref rgGetCredentialData);
string src = "/_layouts/OWARedirect.htm?l=" + rgGetCredentialData[0] + "&p=" + rgGetCredentialData[1];
writer.Write("<iframe frameborder=\"0\" width=\"800\" height=\"600\" src=\"" + src + "\"/>");
}
catch (SingleSignonException ssoe)
{
if (SSOReturnCodes.SSO_E_CREDS_NOT_FOUND == ssoe.LastErrorCode)
{
Context.Response.Redirect(strSSOLogonFormUrl);
}
else
{
writer.Write(ssoe.Message);
}
}
}
}
}
替代那个MOSS自带的WebPart,如果你的OWA采用Form方式验证的话,基本上那个WebPart没有任何作用!
再在_layouts下建个html重定向文件:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; CHARSET=utf-8" />
<meta name="Robots" content="NOINDEX, NOFOLLOW" />
<title>Microsoft Exchange - Outlook Web Access</title>
<script type="text/javascript">
<!--
function getParameter(queryString, parameterName) {
var parameterName = parameterName + "=";
if (queryString.length > 0) {
begin = queryString.indexOf(parameterName);
if (begin != -1) {
begin += parameterName.length;
end = queryString.indexOf("&", begin);
if (end == -1) {
end = queryString.length;
}
return unescape(queryString.substring(begin, end));
}
return "null";
}
}
function SetParams() {
var queryString = window.location.search.substring(1);
logonForm.username.value = getParameter(queryString, "l");
logonForm.password.value = getParameter(queryString, "p");
//alert(getParameter(queryString, "l"));
//alert(getParameter(queryString, "p"));
window.document.logonForm.submit();
}
-->
</script>
</head>
<body onload="SetParams();">
Please wait
<form action="https://moss.demo.fr/owa/auth/owaauth.dll" method="POST" name="logonForm"
autocomplete="off">
<input type="hidden" name="destination" value="https://moss.demo.fr/owa/" />
<input type="hidden" name="flags" value="0" />
<input type="hidden" name="forcedownlevel" value="0" />
<input id="rdoPblc" type="hidden" name="trusted" value="0" />
<input id="username" name="username" type="hidden" />
<input id="password" name="password" type="hidden" />
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; CHARSET=utf-8" />
<meta name="Robots" content="NOINDEX, NOFOLLOW" />
<title>Microsoft Exchange - Outlook Web Access</title>
<script type="text/javascript">
<!--
function getParameter(queryString, parameterName) {
var parameterName = parameterName + "=";
if (queryString.length > 0) {
begin = queryString.indexOf(parameterName);
if (begin != -1) {
begin += parameterName.length;
end = queryString.indexOf("&", begin);
if (end == -1) {
end = queryString.length;
}
return unescape(queryString.substring(begin, end));
}
return "null";
}
}
function SetParams() {
var queryString = window.location.search.substring(1);
logonForm.username.value = getParameter(queryString, "l");
logonForm.password.value = getParameter(queryString, "p");
//alert(getParameter(queryString, "l"));
//alert(getParameter(queryString, "p"));
window.document.logonForm.submit();
}
-->
</script>
</head>
<body onload="SetParams();">
Please wait
<form action="https://moss.demo.fr/owa/auth/owaauth.dll" method="POST" name="logonForm"
autocomplete="off">
<input type="hidden" name="destination" value="https://moss.demo.fr/owa/" />
<input type="hidden" name="flags" value="0" />
<input type="hidden" name="forcedownlevel" value="0" />
<input id="rdoPblc" type="hidden" name="trusted" value="0" />
<input id="username" name="username" type="hidden" />
<input id="password" name="password" type="hidden" />
</form>
</body>
</html>
部署后即可测试了!附件给出owa 2003 和 2007的代码源文件!
此处下载
msn: pccai1983@hotmail.com