Enumerating the User List and Obtaining User Info:http://vbnet.mvps.org/code/network/netuserenum.htm
有API可以实现。Network Management FunctionsThe network management functions can be grouped as follows.Alert FunctionsNetAlertRaise NetAlertRaiseEx API Buffer FunctionsNetApiBufferAllocate NetApiBufferFree NetApiBufferReallocate NetApiBufferSize Directory Service FunctionsNetGetJoinableOUs NetGetJoinInformation NetJoinDomain NetRenameMachineInDomain NetUnjoinDomain NetValidateName Distributed File System (Dfs) FunctionsNetDfsAdd NetDfsAddFtRoot NetDfsAddStdRoot NetDfsAddStdRootForced NetDfsEnum NetDfsGetClientInfo NetDfsGetInfo NetDfsManagerInitialize NetDfsRemove NetDfsRemoveFtRoot NetDfsRemoveFtRootForced NetDfsRemoveStdRoot NetDfsSetClientInfo NetDfsSetInfo Get FunctionsNetGetAnyDCName NetGetDCName NetGetDisplayInformationIndex NetQueryDisplayInformation Group FunctionsNetGroupAdd NetGroupAddUser NetGroupDel NetGroupDelUser NetGroupEnum NetGroupGetInfo NetGroupGetUsers NetGroupSetInfo NetGroupSetUsers Local Group FunctionsNetLocalGroupAdd NetLocalGroupAddMembers NetLocalGroupDel NetLocalGroupDelMembers NetLocalGroupEnum NetLocalGroupGetInfo NetLocalGroupGetMembers NetLocalGroupSetInfo NetLocalGroupSetMembers Message FunctionsNetMessageBufferSend NetMessageNameAdd NetMessageNameDel NetMessageNameEnum NetMessageNameGetInfo NetFile FunctionsNetFileClose NetFileClose2 NetFileEnum NetFileGetInfo Remote Utility FunctionsNetRemoteComputerSupports NetRemoteTOD Replicator FunctionsNetReplExportDirAdd NetReplExportDirDel NetReplExportDirEnum NetReplExportDirGetInfo NetReplExportDirLock NetReplExportDirSetInfo NetReplExportDirUnlock NetReplGetInfo NetReplImportDirAdd NetReplImportDirDel NetReplImportDirEnum NetReplImportDirGetInfo NetReplImportDirLock NetReplImportDirUnlock NetReplSetInfo Schedule FunctionsNetScheduleJobAdd NetScheduleJobDel NetScheduleJobEnum NetScheduleJobGetInfo GetNetScheduleAccountInformation SetNetScheduleAccountInformation Server FunctionsNetServerDiskEnum NetServerEnum NetServerGetInfo NetServerSetInfo Server and Workstation Transport FunctionsNetServerComputerNameAdd NetServerComputerNameDel NetServerTransportAdd NetServerTransportAddEx NetServerTransportDel NetServerTransportEnum NetWkstaTransportAdd NetWkstaTransportDel NetWkstaTransportEnum Session FunctionsNetSessionDel NetSessionEnum NetSessionGetInfo Share FunctionsNetConnectionEnum NetShareAdd NetShareCheck NetShareDel NetShareEnum NetShareGetInfo NetShareSetInfo Statistics FunctionNetStatisticsGet Use FunctionsNetUseAdd NetUseDel NetUseEnum NetUseGetInfo User FunctionsNetUserAdd NetUserChangePassword NetUserDel NetUserEnum NetUserGetGroups NetUserGetInfo NetUserGetLocalGroups NetUserSetGroups NetUserSetInfo User Modals FunctionsNetUserModalsGet NetUserModalsSet Workstation and Workstation User FunctionsNetWkstaGetInfo NetWkstaSetInfo NetWkstaUserGetInfo NetWkstaUserSetInfo NetWkstaUserEnum Other FunctionsNetValidatePasswordPolicyFree NetValidatePasswordPolicyFor a list of additional networking functions, see Windows Networking Functions. Access and Security Functions (Windows 95/98/Me only)NetAccessAdd NetAccessCheck NetAccessDel NetAccessEnum NetAccessGetInfo NetAccessGetUserPerms NetAccessSetInfo NetSecurityGetInfo
Enumerating Local Groups and Descriptions with NetLocalGroupEnum:http://vbnet.mvps.org/code/network/netlocalgroupenumdesc.htm
Private Sub Form_Load() sComputer = "127.0.0.1" Set cont1 = GetObject("WinNT://" & sComputer & ",computer") 'We want only users. cont1.Filter = Array("user") Debug.Print "************User list***************" For Each usr In cont1 Debug.Print usr.Name Next
Set cont2 = GetObject("WinNT://" & sComputer & ",computer") 'We want only groups. cont2.Filter = Array("Group") Debug.Print "***********group info***************" For Each grp In cont2 Debug.Print grp.Name Set memberList = grp.members For Each member In memberList Debug.Print " "; member.Name & "(" & member.Class & ")" Next Next End Sub
NetAlertRaiseEx
API Buffer FunctionsNetApiBufferAllocate
NetApiBufferFree
NetApiBufferReallocate
NetApiBufferSize
Directory Service FunctionsNetGetJoinableOUs
NetGetJoinInformation
NetJoinDomain
NetRenameMachineInDomain
NetUnjoinDomain
NetValidateName
Distributed File System (Dfs) FunctionsNetDfsAdd
NetDfsAddFtRoot
NetDfsAddStdRoot
NetDfsAddStdRootForced
NetDfsEnum
NetDfsGetClientInfo
NetDfsGetInfo
NetDfsManagerInitialize
NetDfsRemove
NetDfsRemoveFtRoot
NetDfsRemoveFtRootForced
NetDfsRemoveStdRoot
NetDfsSetClientInfo
NetDfsSetInfo
Get FunctionsNetGetAnyDCName
NetGetDCName
NetGetDisplayInformationIndex
NetQueryDisplayInformation
Group FunctionsNetGroupAdd
NetGroupAddUser
NetGroupDel
NetGroupDelUser
NetGroupEnum
NetGroupGetInfo
NetGroupGetUsers
NetGroupSetInfo
NetGroupSetUsers
Local Group FunctionsNetLocalGroupAdd
NetLocalGroupAddMembers
NetLocalGroupDel
NetLocalGroupDelMembers
NetLocalGroupEnum
NetLocalGroupGetInfo
NetLocalGroupGetMembers
NetLocalGroupSetInfo
NetLocalGroupSetMembers
Message FunctionsNetMessageBufferSend
NetMessageNameAdd
NetMessageNameDel
NetMessageNameEnum
NetMessageNameGetInfo
NetFile FunctionsNetFileClose
NetFileClose2
NetFileEnum
NetFileGetInfo
Remote Utility FunctionsNetRemoteComputerSupports
NetRemoteTOD
Replicator FunctionsNetReplExportDirAdd
NetReplExportDirDel
NetReplExportDirEnum
NetReplExportDirGetInfo
NetReplExportDirLock
NetReplExportDirSetInfo
NetReplExportDirUnlock
NetReplGetInfo
NetReplImportDirAdd
NetReplImportDirDel
NetReplImportDirEnum
NetReplImportDirGetInfo
NetReplImportDirLock
NetReplImportDirUnlock
NetReplSetInfo
Schedule FunctionsNetScheduleJobAdd
NetScheduleJobDel
NetScheduleJobEnum
NetScheduleJobGetInfo
GetNetScheduleAccountInformation
SetNetScheduleAccountInformation
Server FunctionsNetServerDiskEnum
NetServerEnum
NetServerGetInfo
NetServerSetInfo
Server and Workstation Transport FunctionsNetServerComputerNameAdd
NetServerComputerNameDel
NetServerTransportAdd
NetServerTransportAddEx
NetServerTransportDel
NetServerTransportEnum
NetWkstaTransportAdd
NetWkstaTransportDel
NetWkstaTransportEnum
Session FunctionsNetSessionDel
NetSessionEnum
NetSessionGetInfo
Share FunctionsNetConnectionEnum
NetShareAdd
NetShareCheck
NetShareDel
NetShareEnum
NetShareGetInfo
NetShareSetInfo
Statistics FunctionNetStatisticsGet
Use FunctionsNetUseAdd
NetUseDel
NetUseEnum
NetUseGetInfo
User FunctionsNetUserAdd
NetUserChangePassword
NetUserDel
NetUserEnum
NetUserGetGroups
NetUserGetInfo
NetUserGetLocalGroups
NetUserSetGroups
NetUserSetInfo
User Modals FunctionsNetUserModalsGet
NetUserModalsSet
Workstation and Workstation User FunctionsNetWkstaGetInfo
NetWkstaSetInfo
NetWkstaUserGetInfo
NetWkstaUserSetInfo
NetWkstaUserEnum
Other FunctionsNetValidatePasswordPolicyFree
NetValidatePasswordPolicyFor a list of additional networking functions, see Windows Networking Functions.
Access and Security Functions (Windows 95/98/Me only)NetAccessAdd
NetAccessCheck
NetAccessDel
NetAccessEnum
NetAccessGetInfo
NetAccessGetUserPerms
NetAccessSetInfo
NetSecurityGetInfo
sComputer = "127.0.0.1"
Set cont1 = GetObject("WinNT://" & sComputer & ",computer")
'We want only users.
cont1.Filter = Array("user")
Debug.Print "************User list***************"
For Each usr In cont1
Debug.Print usr.Name
Next
Set cont2 = GetObject("WinNT://" & sComputer & ",computer")
'We want only groups.
cont2.Filter = Array("Group")
Debug.Print "***********group info***************"
For Each grp In cont2
Debug.Print grp.Name
Set memberList = grp.members
For Each member In memberList
Debug.Print " "; member.Name & "(" & member.Class & ")"
Next
Next
End Sub