Results 1 to 10 of 10

Thread: To get the list of NT domains and Users

  1. #1
    Guest

    Question

    Hi,
    1. How do i get a list of all the NT domains available thru my VB code, which is the API call that i have to make?
    2. How do i get the list of all NT users in a particular domain?Again the name of the API that i may have to use?

    Something like when i log into a NT workstation(ctrl+alt+del), i get a list of the available domains, i want a similar list of all the domains that is available.

    Thanks,
    Desi

  2. #2
    New Member
    Join Date
    Apr 2000
    Posts
    4
    You might want to look into ADSI. With ADSI, you can enumerate Domains,Computers, and Users. In addition it gives you a number of other advantages when working with these areas.

  3. #3
    Guest
    Hi Hudgi,
    What is ADSI??Could u please elaborate.
    Thanks,
    Desi

  4. #4
    New Member
    Join Date
    Apr 2000
    Posts
    4
    ADSI is Active Directory Services Interface. It's a product by Microsoft and works in conjunction with VB. You can Download ADSI from Microsoft. It allows you to access and modifiy NT related components without bulky coding.

    Example: ( This Enumerations Computers from a Domain)
    '-- Declarations
    Dim Domain As IADsContainer
    Dim comp As IADsComputer
    Dim vfilter As Variant


    '-- Initialize
    Set Domain = GetObject("WinNT://" & sDomainName)
    vfilter = Array("computer")
    Domain.Filter = vfilter

    '--
    ' Error Trapping
    On Error GoTo errhandler
    '--
    '--Information Settings
    FrmMain.StatusBar1.Panels.Item(1).Text = "Enumerating Computers, Please Wait"
    FrmMain.StatusBar1.Refresh

    Dim nodX As Node
    Dim x
    Dim i As Long, j As Long, k As Long
    With FrmMain.TreeView1
    With .Nodes
    For Each comp In Domain
    Set nodX = .Add(sDomainName & Computers",tvwChild,sDomainName & comp.Name, comp.Name, 22, 22)

    Next comp
    End With
    End With

    '--
    ' Resets the Variables Used by the Application
    FrmMain.TreeView1.SelectedItem.Expanded = True
    FrmMain.StatusBar1.Panels.Item(1).Text = ""
    FrmMain.StatusBar1.Refresh
    FrmMain.MousePointer = vbDefault

    Exit Sub

    errhandler:
    FrmMain.StatusBar1.Panels.Item(1).Text = "A Error has occured, Please Check Settings"
    FrmMain.StatusBar1.Refresh
    FrmMain.MousePointer = vbDefault

  5. #5
    New Member
    Join Date
    Apr 2000
    Posts
    4
    There is website that has alot of examples and code snippets
    http://www.netfokus.dk/vbadmincode/

  6. #6
    Guest

    Thumbs up

    Thanks pal.I will go thru the site

  7. #7
    Guest
    Hey hudgi what is that sdomainNmae in ur code??
    I kindof dont have time now to go thru the site that u have mentioned.I hope ur code helps.

  8. #8
    New Member
    Join Date
    May 2000
    Location
    Posts
    2

    Problem with adsi functions and getobject

    Hi ,
    Even i have a similar problem, can you help me with it

    I need to my program to pause, resume or cancel any job in the print queue. I am trying to use the ADSI functions to achieve this functionality. But I am having problems trying to use getobject function to access the print queue on my printer.
    I get an error saying "Automation Error . Invalid syntax". My souce code is :

    Dim pq as IADsPrintQueue
    Dim pqo as IADsPrintQueueOperations
    Dim pj as IADsPrintJob

    Set pq = GetObject("WinNT://domain_name/computer_name/printer_name")
    (I get error at the above statement)
    Set pqo = pj
    for each pj in pqo.PrintJobs
    ....
    ..
    next


    Can you help me with this ?
    Thanks in advance for your help

    Kamal



  9. #9
    Lively Member
    Join Date
    Jan 1999
    Location
    Rochester NY, USA
    Posts
    93
    search MSDN for netapi32.dll and it will give you a ton of information on how to get whatever information you want from a windows network and windows machines.. there's also some article here but I don't have the path to it at the moment.

  10. #10
    New Member
    Join Date
    May 2000
    Location
    Posts
    2
    Thanks a lot. But I found out my mistake. I had not installed adsi on my computer. I know its an obvious thing to install it if you are using its function, but thought i would just put it here, so that anybody else does not face the same problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width