简体   繁体   English

从ASP.NET网站登录到Sharepoint

[英]Login to Sharepoint from ASP.NET site

I have a preexisting asp.net site that uses forms authentication. 我有一个使用表单身份验证的asp.net站点。 I am setting up a Sharepoint 2007 site on the same box. 我在同一框上设置一个SharePoint 2007网站。 I would like to use my existing asp.net site authentication and once logged in provide a link to the sharepoint site that has the user auto-logged in. 我想使用现有的asp.net站点身份验证,一旦登录,便提供指向具有用户自动登录权限的共享点站点的链接。

It doesn't matter to me if Windows or Forms auth is used. 对我而言,是否使用Windows或Forms auth都无关紧要。 I tried a couple different things to pass credentials through the response, but was unable to obtain success. 我尝试了几种不同的方法来通过响应传递凭据,但是无法获得成功。 Has anyone done anything similar. 有没有人做过类似的事情。 The tutorials for configuring forms auth on sharepoint just seem over the top and quite unreasonable. 在sharepoint上配置表单auth的教程似乎只是顶部,并且是很不合理的。 There has to be an easier way to either pass credentials or configure custom authentication. 必须有一种更简单的方法来传递凭据或配置自定义身份验证。

Any assistance or tips are greatly appreciated. 任何帮助或提示,将不胜感激。

由于站点位于单独的Web应用程序域中,因此开箱即用可能是不可能的。

I'd say you have a couple of options. 我说你有几个选择。

If your asp.net site and your sharepoint site share the same parent domain then you can set your forms authentication cookie to the parent domain and it will be valid on both. 如果您的asp.net站点和共享点站点共享相同的父域,则可以将表单身份验证cookie设置为父域,并且该身份验证cookie在两个域上均有效。 So site1.example.com and site2.example.com can both read a cookie scoped to .example.com 因此,site1.example.com和site2.example.com都可以读取范围为.example.com的Cookie

System.Web.HttpCookie authcookie = System.Web.Security.FormsAuthentication.GetAuthCookie(UserName, False);
authcookie.Domain = "parent.com";
HttpResponse.AppendCookie(authcookie);
HttpResponse.Redirect(System.Web.Security.FormsAuthentication.GetRedirectUrl(UserName, False));

The other option would be to setup forms authenticatin in SharePoint as you normally would, but to make sure to point to the same database as your asp.net site. 另一个选择是像通常那样在SharePoint中设置表单authenticatin,但是要确保指向与asp.net网站相同的数据库。 In this case you would have to sign in twice, but you would use the same username and password in both cases. 在这种情况下,您将必须登录两次,但在两种情况下都将使用相同的用户名和密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM