小编Guy*_*ssy的帖子

User.Identity在ClaimsIdentity和WindowsIdentity之间波动

我有一个MVC站点,允许使用Forms登录和Windows身份验证登录.我使用自定义MembershipProvider对Active Directory进行身份验证,使用System.Web.Helpers AntiForgery类进行CSRF保护,以及Owin cookie身份验证中间件.

在登录期间,一旦用户通过了针对Active Directory的身份验证,我将执行以下操作:

IAuthenticationManager authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
authenticationManager.SignOut(StringConstants.ApplicationCookie);
var identity = new ClaimsIdentity(StringConstants.ApplicationCookie,
    ClaimsIdentity.DefaultNameClaimType,
    ClaimsIdentity.DefaultRoleClaimType);
if(HttpContext.Current.User.Identity is WindowsIdentity)
{
    identity.AddClaims(((WindowsIdentity)HttpContext.Current.User.Identity).Claims);
}
else
{
    identity.AddClaim(new Claim(ClaimTypes.Name, userData.Name));
}
identity.AddClaim(new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "Active Directory"));
identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, userData.userGuid));
authenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = false }, identity);
Run Code Online (Sandbox Code Playgroud)

我的SignOut函数如下所示:

IAuthenticationManager authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
authenticationManager.SignOut(StringConstants.ApplicationCookie);
Run Code Online (Sandbox Code Playgroud)

登录是通过jQuery.ajax请求执行的.成功后,Window.location会更新到站点的主页面.

使用Forms和IntegratedWindowsAuthentication(IWA)登录都可以,但是在使用IWA登录时遇到了问题.这是发生的事情:

  1. 用户在登录页面上选择IWA并点击提交按钮.这通过ajax请求发送到常规登录操作.
  2. 站点收到请求,看到"使用IWA"选项并重定向到相关操作.发送302响应.
  3. 浏览器自动处理302响应并调用重定向目标.
  4. 过滤器看到请求将转向IWA登录操作,并且User.Identity.IsAuthenticated == false.发送401响应.
  5. 浏览器自动处理401响应.如果用户尚未在浏览器中使用IWA进行身份验证,则会弹出一个弹出窗口(默认浏览器行为).收到凭据后,浏览器会使用用户凭据执行相同的请求.
  6. 站点接收经过身份验证的请求,并模拟用户对Active Directory执行检查.如果用户通过身份验证,我们使用上面的代码完成SignIn.
  7. 用户被转发到该站点的主页面.
  8. 该站点接收加载主页面的请求.这是事情有时出错的地方.
    User.Identity此时的类型为WindowsIdentityAuthenticationType设置为Negotiate …

c# asp.net-mvc claims-based-identity windows-identity owin

8
推荐指数
1
解决办法
878
查看次数

获取Azure AD Graph Helper中的成员组

我使用Graph API查询我的Azure Active Directory,使用该Microsoft.WindowsAzure.ActiveDirectory.GraphHelper项目作为我的请求的基础.

在特定的用例中,我有一个包含数百个用户的组,以及一些组.我希望加载此父组的组成员.我试图请求加载该members属性:

DirectoryService.LoadProperty(school, "members");
Run Code Online (Sandbox Code Playgroud)

我只得到100个结果,所有这些都是用户(同样,该组中有超过100个用户).
我尝试执行a DataServiceQuery但它不支持这样的操作:

var groups = DirectoryService.groups;
Group parentGroup = DirectoryService.groups.Where(it => (it.objectId == parentGroupId)).SingleOrDefault();
groups = (DataServiceQuery<Group>)groups.Where(group => group.memberOf.Contains(parentGroup));
Run Code Online (Sandbox Code Playgroud)

它在第三行失败,表示不支持该表达式.

目前,我能想到的唯一解决方案是加载所有组,LoadPropert(entity, 'memberOf', null)在每个组上运行,然后检查每个组是否是parentGroup的成员(实际上是几个这样的parentGroup之一). 注意-我把nullcontinuationToken空间,因为这些群体应该只有一个父组的成员.

这非常低效,但我似乎找不到任何其他方式!
有没有其他方法可以做我想做的事情?

c# azure-active-directory

6
推荐指数
1
解决办法
8848
查看次数

将参与者添加到Lync会话时出现错误ID 486(源ID 239)

我在Windows 7上运行Lync 2013客户端,连接到Lync 2013 Server.

尝试将参与者添加到Lync对话时,被邀请者将被添加到对话的Participants列表中,但在几秒钟后删除并收到以下消息:

An error occurred.
When contacting your support team, reference error ID 486 (source ID 239).

Troubleshooting information is available online, including best practices for using Lync.

Learn More
Run Code Online (Sandbox Code Playgroud)

我尝试邀请的用户从未接听过电话.

"了解更多"文本是一个链接,发送到:
http://r.office.microsoft.com/r/rlidUCErr10?
clid = 1033&p1 = 0&p2 = 29&p3 = 141&p4 = 141&p5 = 141&p6 = 141此地址依次转发:https:
//support.office.com/en-us/article/Generic-Error-b5517285-d4e0-4a92-a58b-96a066d9f3c9?us = en-US&rs = en-US&us = US

此页面是Lync 2010中 "通用错误"的参考...

我在任何地方都找不到关于此错误的信息......这个错误是什么意思?有办法解决吗?

lync-2013

6
推荐指数
1
解决办法
734
查看次数

使用图形 api 在 Azure 活动目录组中搜索用户

我希望在我的 asp.net mvc 5 应用程序中具有某种具有自动完成功能的人员选择器功能,以搜索特定 Azure AD 组中的用户。这是一个演示“待办事项应用程序”,允许将待办事项分配给属于组成员的用户。

我直接尝试了 Graph API 和 Azure Graph Client 库,但似乎没有找到实现我想要的方法。图 api 允许获取组的成员,但添加过滤器“startswith”失败,因为在添加过滤器时,api 仅返回不包含例如 DisplayName 属性的目录对象......客户端库也没有太大帮助除了批处理功能提供了一种方法但有很多开销......然后我必须获得用户的过滤结果集,而不管组成员身份(使用 api 中的用户列表内容),组的所有成员,然后使用 Linq 找出正确的结果集......对于开发/测试来说可以正常工作,但在有几百个用户的生产中这将是疯狂的......

任何想法或建议将不胜感激。谢谢!

编辑

在我从客户端 Javascript 调用以搜索用户的代码下方;

  • AccessGroupId 是用于授权用户的 Azure AD 组。只有该组的成员才能访问我在自定义 OWin 中间件中处理的 Web 应用程序
  • 该方法旨在用于查找该组中的用户

代码工作正常,如下所示,只是没有应用过滤,这是输入参数 pre(来自 ui 中的文本框)的意图。我得到了访问组的所有成员。

public async Task<JsonResult> FindUser(string pre) 
{
    string AccessGroupId = ConfigurationManager.AppSettings["AccessGroupId"];
    AuthenticationContext authCtx = new AuthenticationContext(String.Format(CultureInfo.InvariantCulture, "{0}/{1}", SecurityConfiguration.LoginUrl, SecurityConfiguration.Tenant));
    ClientCredential credential = new ClientCredential(SecurityConfiguration.ClientId, SecurityConfiguration.AppKey);
    AuthenticationResult assertionCredential = await authCtx.AcquireTokenAsync(SecurityConfiguration.GraphUrl, credential);
    var accessToken = assertionCredential.AccessToken;

    var graphUrl …
Run Code Online (Sandbox Code Playgroud)

c# search graph active-directory azure

5
推荐指数
1
解决办法
8632
查看次数

"net.pipe://"不支持请求的升级

我试图在Windows服务中托管WCF net.pipe服务.我在Windows服务的OnStart()函数中用代码定义服务.我也以类似的方式创建客户端 - 代码.

我已经看到了这个问题,但它似乎总是专门用于在app/web.config文件中定义NetNamedPipe的情况.

尝试调用该服务时,我收到错误:

System.ServiceModel.ProtocolException: The requested upgrade is not supported by 'net.pipe://localhost/manager'. This could be due to mismatched bindings (for example security enabled on the client and not on the server).

Server stack trace: 
   at System.ServiceModel.Channels.ConnectionUpgradeHelper.DecodeFramingFault(ClientFramingDecoder decoder, IConnection connection, Uri via, String contentType, TimeoutHelper& timeoutHelper)
   at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)
   at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper)
   at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
   at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, …
Run Code Online (Sandbox Code Playgroud)

c# wcf netnamedpipebinding

4
推荐指数
1
解决办法
6115
查看次数