有朋友写信问:
请问如何在C#中,按照用户组,分别取得NT的各组用户帐号列表?
用WMI就可以获得用户及用户组信息,
 记得要添加System.Management引用,
 并确保目标机器上WMI服务启动。
代码下载( Account.rar 8KB )
但怎样取得分组列表,WMI中好象没有相关信息,我再想想... ...
  
查了一下MSDN里面关于WMI的参照,找到下面这个东东:
Win32_GroupUser 
The Win32_GroupUser association WMI class relates a group and an account that is a member of that group. 
The following syntax is simplified from MOF code and includes all inherited properties. 
 class Win32_GroupUser : CIM_Component 
 { 
   Win32_Group ref GroupComponent; 
   Win32_Account ref PartComponent; 
 }; 
 Methods 
 This class has no methods. Properties 
 The Win32_GroupUser class has the following properties.  GroupComponent  
 Data type: Win32_Group 
 Access type: Read-only 
 Qualifiers: Key Reference to the instance representing the group of which the account is a member. 
PartComponent  
 Data type: Win32_Account 
 Access type: Read-only 
 Qualifiers: Key Reference to the instance representing the user or system account that is a part of a group of accounts. 
Remarks 
 The Win32_GroupUser class is derived from CIM_Component. Requirements 
 Client: Requires Windows XP, Windows 2000 Professional, or Windows NT Workstation 4.0 SP4 and later. 
 Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0 SP4 and later. 
 Header: Declared in Cimwin32.mof. 
 Namespace: Included in \root\cimv2.==============================
但是取出来的 value 值是一长串字符;
有没有办法直接把 name 取出来呢?
 
 
                     
            
        













 
                    

 
                 
                    