Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5985215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:29:50+00:00 2026-05-22T22:29:50+00:00

Dim de As New System.DirectoryServices.DirectoryEntry() Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As

  • 0
Dim de As New System.DirectoryServices.DirectoryEntry()

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        de.Path = "WinNT://*****".Replace("*****", ActiveDirectory.Domain.GetCurrentDomain.Name)
        Dim Mystream As Object
        MsgBox("Please choose the place you want the file")
        If savefileDialog1.ShowDialog() = DialogResult.OK Then Mystream = savefileDialog1.FileName

    Dim UserFile As String = savefileDialog1.FileName & ".txt"
    Dim fileExists As Boolean = File.Exists(UserFile)
    Using sw As New StreamWriter(File.Open(UserFile, FileMode.OpenOrCreate))
        For Each d As DirectoryEntry In de.Children()
            sw.WriteLine(d.Name)

        Next
    End Using
End Sub

I am getting a large number of entries written out to the text file. The bottom half of the file is all that I really need. The bottom half seems to be the list of all machine names on the domain and the first half is filled with names or printers, and other names that i cannot “pushd \” into.

I am unable to figure out what will cut down this user list and give me only the machine names.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:29:51+00:00Added an answer on May 22, 2026 at 10:29 pm

    I’m not sure if there is much difference in our active directory setups, but I ran the following code in a console application and it only output the AD Names (as expected):

    Module Module1
    
        Sub Main()
            Using de As New System.DirectoryServices.DirectoryEntry
                de.Path = "WinNT://*****".Replace("*****", System.DirectoryServices.ActiveDirectory.Domain.GetCurrentDomain.Name)
                For Each d As System.DirectoryServices.DirectoryEntry In de.Children()
                    If d.SchemaEntry.Name = "User" Then
                        Console.WriteLine(d.Name)
                    End If
                Next
                Console.ReadKey()
            End Using
        End Sub
    
    End Module
    

    EDIT:

    Code change to only output members with the SchemaType of “User”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged Dim SQLData
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim SQLData
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim SQLData
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Literal1.Text =
Private Sub Command1_Click() Dim dom As New DOMDocument Dim http As New XMLHTTP Dim
I have this function: Function WriteTextToFile(ByVal data) Dim file As New System.IO.StreamWriter(E:\storage.txt) file.WriteLine(data) file.Close()
Public extreme_foods As New System.Collections.ArrayList() Dim i As Integer i = 1 For Each
I'm using the following code (System.Data.SQLite within VB.net): Dim SQLconnect As New SQLite.SQLiteConnection() Dim
Should I use this. Imports System.IO Dim myStream As New Stream or this.. Dim
I have the following code: Dim lStatementText As String Dim lStatementString As New System.Text.StringBuilder

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.