我想獲取我的天藍色網站上下文以獲取用戶詳細信息。當我嘗試在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();
}
}
您是否正在遵循教程或代碼示例?你可以在你的問題中分享這些信息嗎? –