Link to home
Start Free TrialLog in
Avatar of NigelRocks
NigelRocks

asked on

Checking for System Names

Experts,

What is the best way to check whether a given system name already exists (Windows XP, VB.NET)?
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

already exists where?
Avatar of NigelRocks
NigelRocks

ASKER

In the system.
ASKER CERTIFIED SOLUTION
Avatar of 3_S
3_S

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm trying to do it with the attached code, but it appears to hang on the For Each line.
    Private Function ExistsSystemUserName(ByVal userName As String) As Boolean
 
        Dim bUserExists As Boolean
 
        Dim oDirectoryEntry As System.DirectoryServices.DirectoryEntry = _
        New System.DirectoryServices.DirectoryEntry("WinNT://{Server}")
 
 
        bUserExists = False
        For Each child As DirectoryEntry In oDirectoryEntry.Children
            If child.SchemaClassName = "User" Then
                If child.Name = userName Then
                    bUserExists = True
                End If
            End If
        Next
 
        Return bUserExists
 
    End Function

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Someone I work with dug up some code that uses that as the argument to DirectoryEntry.  I'm completely new to this, so I'm stabbing in the dark.  How do I find the LDAP server here?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial