type="Microsoft.Office.Server.Security.LdapRoleProvider,Microsoft.Office.Server,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c"
server="WIN-9Y7ER4AZW2T"
port="389"
useSSL="false"
groupContainer="DC=gzgi,DC=com"
groupNameAttribute="cn"
groupNameAlternateSearchAttribute="samAccountName"
groupMemberAttribute="member"
userNameAttribute="sAMAccountName"
dnAttribute="distinguishedName"
groupFilter="(&(ObjectClass=group))"
userFilter="(&(ObjectClass=person))"
scope="Subtree"connectionUsername="gzgi\administrator"connectionPassword="merlin"
/>
三、打开管理中心--安全性--指定Web应用程序用户策略:
1.
2.右边选择对应站点,然后添加用户,
选择人员:
添加权限--完成。
配置成表单登录完成^_^
打开网站集可用该添加的用户登录
4、创建一个vs应用程序,添加一个类文件将作该表单登录的自定义代码登录时的后置代码页面。
cs类文件,自定义代码登录结合单点登录代码:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingLoginControl=System.Web.UI.WebControls.Login;
usingSystem.Security;
usingMicrosoft.SharePoint;
usingMicrosoft.SharePoint.WebControls;
usingMicrosoft.SharePoint.IdentityModel;
usingMicrosoft.SharePoint.IdentityModel.Pages;
usingSystem.IdentityModel.Tokens;
usingMicrosoft.SharePoint.Administration;
usingSystem.Web.Security;
usingSystem.Runtime.InteropServices;
usingSystem.Security.Cryptography;
usingSystem.Text;
usingSystem.Collections.Specialized;
usingSystem.Xml;
namespaceFormsSignInPage
{
publicpartialclass_Default:
IdentityModelSignInPageBase
{
//protectedLoginControlloginControl;
//protectedEncodedLiteralClaimsFormsPageMessage;
//protectedTextBoxsecureCode;
//protectedEncodedLiteralsecureCodeLit;
protectedvoidPage_Load(objectsender,EventArgse)
{
//try
//{
//ClaimsFormsPageMessage.Text="";
//loginControl.Focus();secureCode=(TextBox)loginControl.FindControl("secureCode");
//secureCodeLit=(EncodedLiteral)loginControl.FindControl("secureCodeLit");
//}
//catch
//(Exceptionex)
//{
//Response.Write(ex.Message);
//}
if(!
IsPostBack)
{
//Response.Write("进?
入?
");
if(Request["IASID"]==null)
{
//Response.Write("进?
入?
1");
try
{
//Response.Write(InterfaceUtility.GetIASID());
if(AppSSOBLL.TOEACAuthenticat(InterfaceUtility.GetIASID(),AppSSOBLL.GetTimeStamp(),
Request.Url.ToString(),""))
{
//todo
}
}
catch(Exceptionee)
{
Response.Write(ee.ToString());
}
}
//接ó受酣笶AC发ぁ?
送í回?
来ぁ?
的?
认?
证¤信?
息¢,如?
果?
通?
过y定¨位?
到?
保馈?
护¤页?
面?
if(Request["IASID"]!
=null)
{
//Response.Write("进?
入?
2");
if(Request["Result"].ToString()=="0")
{
if(AppSSOBLL.ValidateFromEAC(Request["IASID"].ToString(),Request["TimeStamp"].ToString(),
Request["UserAccount"].ToString(),Request["Result"].ToString(),Request["ErrorDescription"].ToString(),
Request["Authenticator"].ToString()))
{
FormsAuthentication.SetAuthCookie(Request["UserAccount"],false);
stringname=Request["UserAccount"].ToString();
stringpass="123";
Submit(name,pass);
//Redircet();
}
}
}
}
}
///
///转到内容页
///
//privatevoidRedircet()
//{
//try
//{
//if(ViewState["ParentUrl"]!
=null)
//{
//stringurl=ViewState["ParentUrl"].ToString();
//ViewState["ParentUrl"]=null;
//System.Web.HttpContext.Current.Response.Redirect(url,false);
//}
//else
//{
////System.Web.HttpContext.Current.Response.Redirect("",false);
//System.Web.HttpContext.Current.Response.Redirect("base.RedirectToSuccessUrl()",false);
//}
//}
//catch(Exceptionex)
//{
//Response.Write(ex.ToString());
//}
//}
///
///根据安全令牌登录
//////
//////安全令牌
privatevoidEstablishSessionWithToken(SecurityTokensecurityToken)
{
if(null==securityToken)
{
thrownewArgumentNullException("securityToken");
}
SPFederationAuthenticationModulefam=SPFederationAuthenticationModule.Current;
if(null==fam)
{
thrownewArgumentException(null,"FederationAuthenticationModule");
}
fam.SetPrincipalAndWriteSessionToken(securityToken);
}
///
///登录
///
protectedvoidSubmit(stringname,stringpass)
{
SecurityTokentoken=null;
if(null!
=(token=GetSecurityToken(name,pass)))
{
EstablishSessionWithToken(token);
base.RedirectToSuccessUrl();
}
}
///
//////登录事件
//////
//////
//////
//protectedvoidsignInControl_Authenticate(objectsender,AuthenticateEventArgse)
//{
//SecurityTokentoken=null;
//LoginControlformsLoginControl=senderasLoginControl;
//if(null!
=(token=GetSecurityToken(formsLoginControl)))
//{
//EstablishSessionWithToken(token);
//e.Authenticated=true;
//base.RedirectToSuccessUrl();
//}
//}
///
//////获取当前web.congif
//////
privateSPIisSettingsIisSettings
{
get
{
SPWebApplicationwebApp=SPWebApplication.Lookup(newUri(SPContext.Current.Web.Url));
SPIisSettingssettings=webApp.IisSettings[SPUrlZone.Default];
returnsettings;
}
}
///
//////设置安全令牌
//////
//////登陆控件
//////安全令牌
privateSecurityTokenGetSecurityToken(stringname,stringpass)
{
SecurityTokentoken=null;
SPIisSettingsiisSettings=IisSettings;
UriappliesTo=base.AppliesTo;
if(string.IsNullOrEmpty(name)||string.IsNullOrEmpty(pass))
returnnull;
SPFormsAuthenticationProviderauthProvider=iisSettings.FormsClaimsAuthenticationProvider;
token=SPSecurityContext.SecurityTokenForFormsAuthentication(appliesTo,authProvider.Membe