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)?
What is the best way to check whether a given system name already exists (Windows XP, VB.NET)?
already exists where?
ASKER
In the system.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.