OrionCookies
Programmer
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
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