好的,这是我的情况:我有一个在我的SP 2013 IIS网站上安装和运行的ASP.NET Web表单应用程序。 SP是设置为使用Windows Auth的设置。我知道这是非常不寻常的,而不是推荐,但现在我必须这样。即,我没有时间将此和许多其他ASP.NET应用程序转换为SP应用程序。我想做的就是让登录SP的用户并使用该信息对我的ASP.NET应用程序进行身份验证 - 也不会在ASP.NET上提示auth。我认为.NET应用程序的性质运行在与SP 2013相同的IIS中,它不会提示Auth Creds第二次。但是如何从令牌获取用户信息?

我有代码,如

Dim strEmailAddress As String = HttpContext.Current.User.Identity.Name.ToLower
.

在我的ASP.NET(VB.NET)中以及它返回的是: 0#.w | smg \ myuser

所以当我理解它是使用基于声明的身份验证,这是一个索赔令牌。我的问题是如何解析/接受这个令牌来获取用户名,然后在我的ASP.NET中使用它?

网上的其他人已经显示了以下解决方案,但我认为我的应用程序无法使用Microsoft.SharePoint.Administration.claims命名空间。这是简单的吗?

string userName = null;
SPClaimProviderManager mgr = SPClaimProviderManager.Local;
if (mgr != null)
{
    userName = mgr.DecodeClaim(SPContext.Current.Web.CurrentUser.LoginName).Value;
}
.

我理解它spclaimprovidermanager在microsoft.sharepoint.administration.claims命名空间中,但我如何在我的ASP.NET中获得引用。我甚至无法在SP 2013服务器上找到DLL。

有帮助吗?

解决方案 2

I was able to get this to work using the approach above outlined in my question - i was able to copy Microsoft.Sharepoint assembly from server and reference it in my ASP.NET project. The Microsoft.SharePoint.Administration.Claims namespace is found in the Microsoft.Sharepoint assembly

其他提示

The key is to have both SharePoint and your app use the same authentication source.

So, either your app must change to Windows Auth (aka Integrated NTLM), or SharePoint must use forms (or claims that is based on the same user store).

许可以下: CC-BY-SA归因
scroll top