Q

Checking for a specific user in a domain

Is there a way I can check for the existence of a specific user account in the domain?
You can use the following VB Script to verify that an individual already has an account in the domain. Replace the text in bold with your specific information.
Dim oUser, oDomain
Set oDomain = GetObject("WinNT://"&sDomainName)
oDomain.Filter = Array("user")

For Each oUser In oDomain
If LCase(oUser.Name) = LCase(sUserName) Then
WScript.Echo oUser.Name & " already has an account."
WScript.Quit
End If
Next

This was first published in June 2004

Dig deeper on Microsoft Active Directory

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchServerVirtualization

SearchCloudComputing

SearchExchange

SearchSQLServer

SearchWinIT

SearchEnterpriseDesktop

SearchVirtualDesktop

Close