Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get username and computername with their first and lastname from AD

Status
Not open for further replies.

OrionCookies

Programmer
May 5, 2005
43
US
Hi all,
I am new to vbscript's world. i am trying to get username and computername with their first and lastname from AD.
here is my script
===================================
On Error Resume Next

Dim strTitle
Dim strUserName
Dim dtStart
Dim objConnection
Dim objCommand
Dim objRecordSet
Dim strMsg
Dim strProfilePath

strTitle = "AD User Exist?..."

strUserName = InputBox ("Please enter the account name of the user...",_
strTitle, "<AD_ACCOUNT_NAME>")

If strUserName = "" Then

WScript.Quit

End If

dtStart = TimeValue(Now())

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

objCommand.CommandText ="<LDAP://dc=CORP,dc=microsoft,dc=COM>;(&(objectCategory=User)" _
& "(samAccountName=" & strUserName & "));samAccountName;subtree"

Set objRecordSet = objCommand.Execute

If objRecordset.RecordCount < 1 Then

strMsg = UCase(strUserName) & " does not exist."
MsgBox strMsg, vbInformation, strTitle

Else

strMsg = UCase(strUserName) & " exists."
MsgBox strMsg, vbInformation, strTitle

End If
objConnection.Close
======================================================

Many thanks in advance, if someone can assist me in this
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top