ASP.Net 获取登陆用户信息方法
来源:互联网 发布:多特软件站官方网站 编辑:程序博客网 时间:2024/06/05 11:56
工作需要,asp程序需要获取访问用户的相关信息。查阅大量资料,记录以收藏
1)通过office interop控件可以获取,但发现这种方法并不适用于server端(此方法可在之前帖子中找到)。
http://support.microsoft.com/default.aspx?scid=kb;en-us;257757
2)寻找过其他替代方法,但这些方法需要用户名和密码登陆通过OWA获取,这并不是在server端很好的办法,该方法可参阅:
1. http://weblogs.asp.net/whaggard/archive/2007/01/30/how-do-i-access-my-outlook-contacts-from-my-web-application.aspx
2. http://blogs.msdn.com/webdav_101/archive/2008/06/11/getting-a-list-of-mailboxes.aspx
3)通过Active Directory方式可以获取企业域内的相关信息,域内的服务器可以直接获取而不需要特定用户名密码登陆。
参阅:http://weblogs.asp.net/jpinquie/archive/2008/02/06/how-to-get-domain-user-information-from-active-directory-in-c.aspx
http://www.codeproject.com/KB/exchange/AccessGAL.aspx
主要实现:
using System.DirectoryServices;
string filter = "(&(objectCategory=person)(SAMAccountName=alias))";
DirectorySearcher searcher = new DirectorySearcher(filter);
foreach (SearchResult result in searcher.FindAll())
{
// Do work with data returned for each address entry
DirectoryEntry entry = result.GetDirectoryEntry();
Console.WriteLine("Name: {0} {1}/nEmail: {2}/nPhone: {3}/nDisplayName:{4}",
entry.Properties["givenName"].Value,
entry.Properties["sn"].Value,
entry.Properties["mail"].Value,
entry.Properties["telephonenumber"].Value,
entry.Properties["displayname"].Value
);
//if the properties has more than 1 items, use the method below
if (entry.Properties["memberof"].Count > 0)
{
for (int i = 0; i < entry.Properties["memberof"].Count; i++)
{
string group = entry.Properties["memberof"][i].ToString();
if (group.StartsWith("CN="))
{
group = group.Substring(3, group.IndexOf(',') - 3);
}
//Console.WriteLine(entry.Properties["memberof"][i].ToString());
Console.WriteLine("======"+group+"=============");
}
}
- ASP.Net 获取登陆用户信息方法
- 登陆获取用户信息
- QQ登陆获取用户信息
- asp.net IIS 部署报错/获取不到当前用户信息 配置方法
- QQ登陆,获取QQ用户信息
- android Facebook登陆获取用户信息
- android Line登陆获取用户信息
- asp.net获取用户登陆IP
- android中使用Twitter登陆获取用户信息
- 微信第三方登陆,无需注册一键登录,获取用户信息,PHP实现方法
- asp.net 获取参数方法
- IIS7,ASP.net 2.0获取客户端登陆用户名
- ASP.net如何访问域用户信息
- 使用ASP.NET 2.0 Profile存储用户信息
- 使用ASP.NET 2.0 Profile存储用户信息
- 使用ASP.NET 2.0 Profile存储用户信息
- 使用ASP.NET 2.0 Profile存储用户信息
- 使用ASP.NET 2.0 Profile存储用户信息
- Commons-beanutils使用指南
- 消息摘要算法简介
- 获得文件夹中的文件列表
- 原来有一个博客这么简单!
- asp.net操作xml
- ASP.Net 获取登陆用户信息方法
- ls 命令可以说是Linux下最常用的命令之一。它有众多的选项,其中有很多是很有用的,你是否熟悉呢?下面列出了 ls 命令的绝大多数选项。
- 杨争管理实践日志---懂得欢庆
- Linux新手必须掌握的概念——挂载点
- J2ME高级界面和低级界面的跳转
- linux解压tar命令
- 用YSlow分析我们页面
- linux tar命令详解
- Java中使用SSHA对数据进行加密的示例