我想获取我的天蓝色网站上下文以获取用户详细信息。当我尝试在servername上获取上下文时,我的代码在此时失败,这是第二个参数。在这种情况下,我可以在哪里从azure拉取服务器名称。我从here发现了一些信息。天青活动目录用户原则上下文服务器名称
using (PrincipalContext context = new PrincipalContext(ContextType.Domain, "mysitename.azurewebsites.net"))
完整的代码示例
static GroupPrincipal[] GetUserAuthorisationGroups(string userPrincipalName)
{
using (PrincipalContext context = new PrincipalContext(ContextType.Domain, "mysitename.azurewebsites.net"))
using (UserPrincipal user = UserPrincipal.FindByIdentity(context, IdentityType.UserPrincipalName, userPrincipalName))
{
return user.GetAuthorizationGroups().OfType<GroupPrincipal>().ToArray();
}
}
您是否正在遵循教程或代码示例?你可以在你的问题中分享这些信息吗? –