编程需要一个本域所以用户账号的列表
请问如何取到

解决方案 »

  1.   

    c:>net user >>c:\1.txt然后处理此1.txt即可
      

  2.   

    楼上的方法简单易用
    shell "c:\winnt\system32\cmd.exe /c net user>c:\1.txt",vbhide'延时判断文件是否已生成,然后处理即可另外还可以通过Active DS Type Library来访问AD目录请参照下面的帖子:
    http://expert.csdn.net/Expert/topic/1206/1206758.xml?temp=.7006189
      

  3.   

    我试了一下,NET USER
    只能显示本地PC
    的用户列表
    好象不能列出指定域的
      

  4.   

    '需要引用Active DS Type LibraryPrivate Sub Command1_Click()
    Dim objContainer As IADsContainer
    Dim objUser As IADsUser
    Dim strServerFullName, strDomainName As StringList1.ClearIf Trim(Text1.Text) = "" Then
       MsgBox "Server Name is Empty!" & vbCrLf & "Please Input!", vbExclamation, "Error"
       Text1.SetFocus
       Exit Sub
    End If
    strServerFullName = Text1.Text
    If InStr(strServerFullName, ".") = 0 Then
       DomainName = ""
    Else
       strDomainName = "DC=" & Replace(Right(strServerFullName, Len(strServerFullName) - InStr(strServerFullName, ".")), ".", ",DC=")
    End If' get the container
    On Error GoTo ErrHandler
    Set objContainer = GetObject("LDAP://" + strServerFullName + "/CN=Users," + strDomainName)
    For Each Child In objContainer
        On Error Resume Next
        Set objUser = Child
        If Err.Number = 0 Then
           List1.AddItem Right(Child.Name, Len(Child.Name) - 3)
        End If
    Nextstr_DomainName = strDomainName
    List1.SetFocusExit SubErrHandler:
    MsgBox "Can't get users list from [ " & Text1.Text & " ].", vbExclamation, "Error"
    SendKeys "{Home}+{End}"
    Text1.SetFocus
    Exit SubEnd Sub