如何使用C#.net在网络相关环境中获取所有用户的Windows帐户名? [英] How to fetch all user's windows account name in a network related environment using C# .net?

查看:106
本文介绍了如何使用C#.net在网络相关环境中获取所有用户的Windows帐户名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用C#.net在网络相关环境中获取所有用户的Windows帐户名?我正在使用C#2.0。



我可以按如下方式获取登录用户的Windows帐户名称:



lblUserName.Text = System .Windows.Forms.SystemInformation.UserName.ToString();



我希望所有用户的列表都有他们的Windows帐户名。

How to fetch all user's windows account name in a network related environment using C# .net? I am using C#2.0.

I could get the logged in user's windows account name as follows:

lblUserName.Text = System.Windows.Forms.SystemInformation.UserName.ToString();

I want the list of all users with their windows account name.

推荐答案

要检索.NET 2.0中Active Directory域中所有用户的列表,您需要使用 System.DirectoryServices 程序集/命名空间 [ ^ ]。

获取C#中的Active Directory用户列表 [ ^ ]



如果你可以升级到.NET 3.5或更高版本, System.DirectoryServices.AccountManagement 程序集/命名空间 [ ^ ]提供了一个更简单的API来做同样的事情。

使用System.DirectoryServices.AccountManagement [ ^ ]。
To retrieve the list of all users in an Active Directory domain in .NET 2.0, you'll need to use the System.DirectoryServices assembly / namespace[^].
Get List of Active Directory Users in C#[^]

If you can upgrade to .NET 3.5 or higher, the System.DirectoryServices.AccountManagement assembly / namespace[^] provides a simpler API for doing the same thing.
Using System.DirectoryServices.AccountManagement[^].


这篇关于如何使用C#.net在网络相关环境中获取所有用户的Windows帐户名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆