在ASP.NET中获得域用户及域名的办法?
各位我在程序中要获得域用户及域名,参考了一些文章,写了如下代码:
string txtUser=Page.User.Identity.Name;
同时在web.config中设为windows方式,取出的值总是为空,请各位指点!!
问题点数:0、回复次数:5Top
1 楼doctorxiajian(xj)回复于 2003-11-04 21:05:26 得分 0
没有人知道吗?
请大家指点指点Top
2 楼orangeam(橙汁)回复于 2003-11-04 21:15:28 得分 0
WindowsIdentity id=( WindowsIdentity )User.Identity;
string txtUser = id.Name;
=============================================
try it.Top
3 楼redbb(....DB & DEV....抵制日货,人人有责...)回复于 2003-11-04 22:44:41 得分 0
protected string[] GetSchemaProperties(string schemaNamingContext, string objectType)
{
string[] data;
using (DirectoryEntry de = new DirectoryEntry())
{
de.Username = username;
de.Password = password;
de.Path = "LDAP://" + hostname + "CN=" + objectType + "," + schemaNamingContext;
DS.PropertyCollection properties = de.Properties;
DS.PropertyValueCollection values = properties["systemMayContain"];
data = new String[values.Count];
values.CopyTo(data, 0);
}
return data;
}Top
4 楼doctorxiajian(xj)回复于 2003-11-05 09:13:58 得分 0
to orangeam(橙汁) 你讲的办法只能取得用户名,没有域名
to redbb(. Dotneter .) DS是各什么东西?能不能讲详细些?谢谢!Top
5 楼tangqingqiong(唐朝)回复于 2003-12-02 14:27:32 得分 0
to orangeam(橙汁)的的确获得了域名和用户名(域名\用户名)
分析一下即可。Top




