我需要在SharePoint 2010中为声明用户执行搜索模拟.为了说明这一点,我想首先说明如何使用Windows帐户,然后讨论Claims/WIF.
我可以使用以下方法为"经典"Windows集成身份验证用户执行此操作:
WindowsImpersonationContext wic = null;
try
{
WindowsIdentity impersonatedUser = new WindowsIdentity("john.doe@mydomain");
wic = impersonatedUser.Impersonate();
// do impersonated work here...
// in my case this is a SharePoint KeywordQuery
}
finally
{
if (wic != null)
{
wic.Undo();
}
}
Run Code Online (Sandbox Code Playgroud)
为了使上述功能得以实现,模拟帐户必须与当前用户位于同一个域中,我必须确保应用程序池所有者是:
(注意:如果有人可以弄清楚如何解决当前帐户必须与模拟帐户位于同一域中的问题,我很满意.)
我想对Claims/WIF帐户做同样的事情.这些帐户并不一定与AD帐户(我需要承担他们不是)相关联.
有没有办法告诉STS我想冒充某个特定帐户并为它提供该帐户的相应令牌?我没有我冒充用户的密码.
引用SharePoint Brew我必须应对在SharePoint Web前端(WFE)上运行的代码,该代码通过WCF调用调用查询处理器.我希望WCF调用位于模拟用户的上下文中.
WFE(Server1)搜索Web部件与服务应用程序代理进行通信.关联的搜索服务应用程序代理调用本地STS以获取用户的SAML令牌.收集SAML令牌后,搜索服务应用程序代理将通过WCF调用调用运行查询处理器的服务器.我将这个服务器称为"服务器2".服务器2接收传入请求并根据其本地STS验证SAML令牌.经过验证,Server 2连接到各种组件以收集,合并和安全性修剪搜索结果.服务器2将修剪后的搜索结果发送回服务器1,然后将其呈现给用户.
更多的研究使我看到ActAs和OnBehalfOf.我相信我会想要使用OnBehalfOf,但我不确定是否会有效.我发现的一些参考文献列在下面.任何指导表示赞赏.
有没有办法获取Windows身份验证用户所在的角色列表,而无需通过WindowsPrincipal.IsInRole方法明确检查?
ADAM,Active Directory,LDAP,ADFS,Windows Identity,卡片空间和哪个服务器(Windows 2003,Windows 2008)使用什么之间有什么区别/关系?
我有一个使用ASP.NET表单身份验证的ASP.NET 3.5应用程序.我希望能够在页面中编辑数据时获取当前登录到计算机的Windows用户名(不登录到ASP.NET应用程序,但登录到Windows).
如果我使用Context.User.Identity.Name.Tostring(),我会将用户名登录到ASP.NET应用程序中,但我需要Windows帐户名.
System.Security.Principal.WindowsIdentity.GetCurrent().Name.Tostring()
Run Code Online (Sandbox Code Playgroud)
此外,它仅在我从Visual Studio运行网站时有效,但在部署到IIS后,它返回NT AUTHORITY\SYSTEM.
该WindowsIdentity(string)构造函数需要的用户名是在username@domain.com格式.但在我的情况下,我以旧DOMAIN\user格式从数据库中获取用户名(然后必须检查其Windows角色成员身份).
WindowsPrincipal从旧式用户名创建的最佳方法是什么?
我正在使用HttpContext.Current.User.Identity.Name来获取Web应用程序正在使用时的用户名.在开发过程中,我使用了我的本地iis,启用了集成的Windows身份验证,启用了匿名访问和禁用,我能够获得用户名.
现在,当我发布Web应用程序时,它又回来了.已发布服务器上的设置是相同的,我尝试使用Page.User.Identity.Name,它也返回空白.
有谁知道这是为什么以及如何解决它?
ReSharper警告我有可能NullReferenceException进入
WindowsIdentity windowsIdentity = new WindowsIdentity(WindowsIdentity.GetCurrent().Token);
Run Code Online (Sandbox Code Playgroud)
我查看了MSDN文档,但没有看到任何提及.此外,它没有意义,因为如果您运行可执行文件,您必须登录.
这只是一个ReSharper搜索模式吗?
在MVC4中,我<authentication mode="Windows"/>在web.config中启用并创建了一个自定义角色提供程序,然后自动为您包装WindowsIdentitya RolePrincipal.工作就像一个魅力.
你会如何使用OWIN和/或Microsoft.ASPNET.Identity在MVC5中执行此操作?
authentication roleprovider windows-identity owin asp.net-mvc-5
我正在使用带有MSSQL后端的MVC3 构建Intranet应用程序.我有身份验证和角色(通过自定义角色提供程序)正常工作.我现在要做的是重写User.Identity以允许像User.Identity.FirstName这样的项目.但我找不到任何代码可以告诉我在WindowsIdentity中如何做到这一点
我试过写一个自定义提供程序:
public class CPrincipal : WindowsPrincipal
{
UserDAL userDAL = new UserDAL();
public CPrincipal(WindowsIdentity identity)
: base(identity)
{
userInfo = userDAL.GetUserProfile(identity.Name.Split('\\')[1]);
this.identity = identity;
}
public UserInfo userInfo { get; private set; }
public WindowsIdentity identity { get; private set; }
}
Run Code Online (Sandbox Code Playgroud)
并覆盖WindowsAuthentication以填充自定义主体.
void WindowsAuthentication_OnAuthenticate(object sender, WindowsAuthenticationEventArgs e)
{
if (e.Identity != null && e.Identity.IsAuthenticated)
{
CPrincipal cPrincipal = new CPrincipal(e.Identity);
HttpContext.Current.User = cPrincipal;
}
}
Run Code Online (Sandbox Code Playgroud)
我在身份验证功能中有一个断点,并且正在填充主体; 但是,当我在控制器中放置一个断点时,User只是它的正常RolePrincipal,而不是我的自定义主体.我究竟做错了什么?
编辑:
我在global.asax中注释掉了上面的代码.我使用C#覆盖了AuthorizeAttribute:
public class CAuthorize : AuthorizeAttribute
{ …Run Code Online (Sandbox Code Playgroud) intranet windows-authentication windows-principal windows-identity asp.net-mvc-3
我知道以下函数以domain\username格式返回当前Windows用户的名称.
Convert.ToString( WindowsIdentity.GetCurrent().Name );
Run Code Online (Sandbox Code Playgroud)
但是如何以username@domain格式获取用户名?
编辑:
我在这个编辑中做出回应,因为回复的每个人都有相同的基本想法.
根据我的理解,从domain\username格式中解析名称并将其构造为username@domain不安全或建议.我相信这是因为不能保证这两个域名在不同的格式中是相同的.例如,在我工作的公司中,格式的domain一部分domain\username基于deparment,但在username@domain,它是公司名称.这是需要DNS查找的事情.
我希望有一个API执行此DNS查找.我想我应该把这些信息放到原来的问题中.抱歉.