ProfileProvider:检索的清单的所有档案
-
05-07-2019 - |
题
我在发展中的一个asp.net 内联网网站有一个ActiveDirectoryMembershipProvider和SqlProfileProvider.
其中一个要求我的网站是有一个"生日"的网页,这将需要我列出所有档案和检索的生日的信息。
我走近的问题如下:
- 援引的成员。GetAllUsers()静态的方法;
- 迭代表的用户和检索的档案件的用户名
这种方法,然而,失败的原因如下:
- 该网络应用程序模拟当前记录的用户检索其广告的详细信息(身份模拟="真正的"中的网站。配置文件),所以我获得一个例外"拒绝访问"时,试图援引GetAllUsers
- 如果我尝试来使该网络应用程序模拟超级用户的帐户,然后返回的广告的用户名称为用户名@域的名字的格式,但在我的个人资料提供商,他们最初被储存作为域名\用户名的格式。
所以,你将如何处去这个问题为检索整个列表中的配置文件的任何成员的组织?
解决方案 2
有一个ProfileManager与方法GetAllProfiles():
http://msdn.microsoft.com/en-us/library/system.web.profile.profilemanager.getallprofiles.aspx
其他提示
虽然我从来没有这样做之前,你可以尝试创建一次模拟的背景下,当建立呼叫 GetAllUsers
应该取得成功。
看看 http://chiragrdarji.blogspot.com/2007/03/impersonation-using-code.html, 这第一章似乎已经实现的变化在安全方面通过使用 System.Security.Principal.WindowsIdentity
类以及 System.Security.Principal.WindowsImpersonationContext
.可能是值得检查。
ProfileInfoCollection profiles = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All);
foreach (ProfileInfo pi in profiles)
{
ProfileCommon p = Profile.GetProfile(pi.UserName);
countries.Add(p.Country);
}
不隶属于 StackOverflow