Try this out I haven't done no testing, will do tomorrow.

Sorry for the layout, PostPrep does not seem to be working. :-(

Code:
 
; *********************************************************************************
; * Script Name: Find User *
; * Creator: Richard Farthing - Queen Elizabeth Hospital NHS Trust *
; * Date: 1/09/03 *
; * Requirments FileOwner Function, KiXforms v2.3.0 Beta 3, *
; * KiXtart 4.22 Beta 1 *
; *********************************************************************************


Break On ; Break On to allow user to break out

;**********************************************************************************************************
;Checking that KiXtart Forms DLL is Registered
$sid = ReadValue("HKEY_CLASSES_ROOT\Kixtart.Form\CLSID", "")
If NOT ReadValue("HKEY_CLASSES_ROOT\CLSID\$sid\InprocServer32", "ThreadingModel") = "Both"
MessageBox("KiXtart Forms Register DLL Failed, Please contact the IMT Helpdesk on x6049",
"Fin User - KiXtart Forms DLL Register Failed", 0)
Exit 1
EndIf

;**********************************************************************************************************
;Create Object to KiXtart Form
$FORM = CreateObject("Kixtart.Form")

;**********************************************************************************************************
;Main Form

$FORM.Caption = "Find User !!"
$FORM.ScaleHeight = 93
$FORM.ScaleWidth = 250
$FORM.FontSize = 8
$FORM.Center

;**********************************************************************************************************
;Current Directory Label

$lblUserName = $FORM.Label
$lblUserName.Text = "Type in your User Name you wish to search for: "
$lblUserName.Left = 5
$lblUserName.Top = 10
$lblUserName.Width = 380
$lblUserName.Height = 20
$lblUserName.FontSize = 8
$lblUserName.FONTNAME = "Arial"
$lblUserName.Enabled = 0

$UserNameButton = $FORM.CommandButton("Search User")
$UserNameButton.Left = 155
$UserNameButton.Top = 35
$UserNameButton.Width = 75
$UserNameButton.Height = 20
$UserNameButton.FontSize = 8
$UserNameButton.FONTNAME = "Arial"
$UserNameButton.OnClick = "MainFunction()"

$UserNameBox = $FORM.TextBox
$UserNameBox.Left = 15
$UserNameBox.Top = 35
$UserNameBox.Width = 120
$UserNameBox.Height = 20
$UserNameBox.FontSize = 8
$UserNameBox.FONTNAME = "Arial"

$ResultText = $FORM.Label
$ResultText.Left = 5
$ResultText.Top = 65
$ResultText.Width = 210
$ResultText.Height = 20
$ResultText.FontSize = 8
$ResultText.FONTNAME = "Arial"


;**********************************************************************************************************
;Objects within Main Form

$FORM.Show ; Show Form

While $FORM.Visible
$=Execute($FORM.DoEvents)
Loop

Exit 1

;***********************************************************************************************************
;Call Functions & UDF's ****
;***********************************************************************************************************

Function MainFunction()


$UserNameBox.Enabled = 0
$UserNameBox.BackColor = $Form.BackColor
$UserNameBox.Text = Ucase($UserNameBox.Text)
$UserNameButton.Enabled = 0
$Domain="QEH-TR"

Select

Case $UserNameBox.Text = @USERID
$ResultText.ForeColor = Green
$ResultText.Text = "Are You Mad, '"+@USERID+"' is you!!"

Case $UserNameBox.Text = ""
$ResultText.Text = "The User Name field cannot be left blank !!"
$ResultText.ForeColor = Red

Case 1 $ResultText.Text = "Searching for User Name....."
$ResultText.ForeColor = Blue
$rc=fnWMILoggedIn(3,$Domain,$sDomainUser,$sDomainPass)

Select

Case Ubound($rc) = +1
$ResultText.Text = $rc

Case $rc = ""
$ResultText.Text = "User Name cannot be found"
$ResultText.ForeColor = Red

Case 1
For Each $Object In $rc
If $Object = $UserNameBox.Text
$ResultText.Text = $Object
EndIf
Next


EndSelect

EndSelect

Sleep 3

$ResultText.Text = ""
$UserNameButton.Enabled = 1
$UserNameBox.Enabled = 1
$UserNameBox.Text = ""
$UserNameBox.BackColor = "White"
$ResultText.ForeColor = Black

EndFunction

Function fnWMILoggedin(optional $iMode, optional $sComputerName, optional $sUserName, optional $sPassword)
Dim $objLocator, $objWBEM, $sUserNames, $sNameSpace, $sName
Dim $objAdsFso, $objSystem, $sCompName, $objAdsSession

$fnWMILoggedin=''

$iMode=Val($iMode)

$sNameSpace = 'root\CIMV2'

; check to see whether we're connecting to a local or remote computer
$sComputerName=Trim($sComputerName)
Select
Case $sComputerName=@WKSTA
$sCompName=$sComputerName
$sComputerName='.'
Case $sComputerName
$sCompName=$sComputerName
Case 1
$sCompName=@WKSTA
$sComputerName='.'
EndSelect

Select
Case $sUserName AND $sComputerName<>'.'
; create locator object for connection to a remote computer
$objLocator = CreateObject('WbemScripting.SWbemLocator')
If @ERROR
Exit @ERROR
EndIf
; create an credentialed (username/password provided) connection to a remote computer
$objWBEM=$objLocator.ConnectServer($sComputerName,$sNameSpace,$sUserName,$sPassword)
If @ERROR
Exit @ERROR
EndIf
; set the impersonation level
$objWBEM.Security_.ImpersonationLevel = 3
If @ERROR
Exit @ERROR
EndIf
Case 1
;set the impersonation level
$objWBEM=GetObject('winmgmts:{impersonationLevel=impersonate}!\\'+$sComputerName+'\'+$sNameSpace)
If @ERROR
Exit @ERROR
EndIf
EndSelect

If $iMode=0 OR ($iMode & 1)
$objSystem = $objWBEM.ExecQuery('Select UserName from Win32_ComputerSystem')
For Each $sName In $objSystem
If $sName.UserName
ReDim preserve $sUserNames[Ubound($sUserNames)+1]
$sUserNames[Ubound($sUserNames)] = $sName.UserName
EndIf
Next
EndIf

If ($iMode & 2)
$objSystem = $objWBEM.ExecQuery("Select StartName from Win32_Service WHERE State='Running' AND StartName<>'LocalSystem'")
For Each $sName In $objSystem
ReDim preserve $sUserNames[Ubound($sUserNames)+1]
If Left($sName.StartName,2)='.\'
If $sCompName
$sUserNames[Ubound($sUserNames)] = Ucase($sCompName)+SubStr($sName.StartName,2)
Else
$sUserNames[Ubound($sUserNames)] = Ucase(@WKSTA)+SubStr($sName.StartName,2)
EndIf
Else
$sUserNames[Ubound($sUserNames)] = $sName.StartName
EndIf
Next
EndIf

If ($iMode & 4) OR ($iMode & 8)
$objAdsFSO = GetObject('WinNT://'+$sCompName+'/LanmanServer')
For Each $objAdsSession In $objAdsFSO.Sessions
$sName=$objAdsSession.User
Select
Case $sName=''
; inter-server connection
Case Right($sName,1)='$' AND ($iMode & 8) AND AScan($sUserNames,$sName)=-1
ReDim preserve $sUserNames[Ubound($sUserNames)+1]
$sUserNames[Ubound($sUserNames)]=Ucase(Left($sName,Len($sName)-1))
Case Right($sName,1)<>'$' AND ($iMode & 4) AND AScan($sUserNames,$sName)=-1
ReDim preserve $sUserNames[Ubound($sUserNames)+1]
If NOT InStr($sName,'\')
$sUserNames[Ubound($sUserNames)]=$sCompName+'\'+$sName
Else
$sUserNames[Ubound($sUserNames)]=$sName
EndIf
EndSelect
Next
$objAdsFSO = 0
EndIf

$objWBEM=0
$objLocator=0

If Ubound($sUserNames)=0
$sUserNames=$sUserNames[0]
EndIf

$fnWMILoggedin=$sUserNames
Exit @ERROR
EndFunction