如果你想获取当前的用户:(只能获得一个用户)
AuthUser.Text = User.Identity.Name;
AuthType.Text = User.Identity.AuthenticationType;
IsAuthenticated.Text = User.Identity.IsAuthenticated.ToString();
如果你想要获得所有WinNT用户:
#region 获取Domain中的User列表,返回ArrayList
public static ArrayList GetDomainUser()
{
ArrayList UserList = new ArrayList();
String strPath="LDAP://RootDSE";
DirectoryEntry ent = new DirectoryEntry(strPath);
String str = ent.Properties["defaultNamingContext"][0].ToString();
DirectoryEntry domain = new DirectoryEntry("LDAP://"+str);
foreach(DirectoryEntry child in domain.Children)
{
foreach(DirectoryEntry Nodes in child.Children)
{
string strName =Nodes.Name.Substring(3);
switch (Nodes.SchemaClassName)
{
case "user" :
UserList.Add(strName);
break;
}
}
}
return UserList;
}
#endregion//其中获取用户的各种信息和上面的获取一个用户的方法基本上是一致的
AuthUser.Text = User.Identity.Name;
AuthType.Text = User.Identity.AuthenticationType;
IsAuthenticated.Text = User.Identity.IsAuthenticated.ToString();
如果你想要获得所有WinNT用户:
#region 获取Domain中的User列表,返回ArrayList
public static ArrayList GetDomainUser()
{
ArrayList UserList = new ArrayList();
String strPath="LDAP://RootDSE";
DirectoryEntry ent = new DirectoryEntry(strPath);
String str = ent.Properties["defaultNamingContext"][0].ToString();
DirectoryEntry domain = new DirectoryEntry("LDAP://"+str);
foreach(DirectoryEntry child in domain.Children)
{
foreach(DirectoryEntry Nodes in child.Children)
{
string strName =Nodes.Name.Substring(3);
switch (Nodes.SchemaClassName)
{
case "user" :
UserList.Add(strName);
break;
}
}
}
return UserList;
}
#endregion//其中获取用户的各种信息和上面的获取一个用户的方法基本上是一致的
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货