FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


How to get windows username from Flash or ActionScript 3?





dickyzin
I would like to capture the Windows Login username of the client calling of my flash application from a browser. I've tried javascript but I couldn't use Wshell. Any help would be appreciated. Thanks.
internetjobs
Hi..

Are you using local login or domain login... Finding local account user name is very simple just try this..

Code:
On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
strComputer = "."

   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount",,48)

strFile = "C:\export.xls"

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objExcel.Workbooks.Add

objExcel.Cells(1,1).Value = "List Users"
objExcel.Cells(2,1).Value = "Time: " & Now

objExcel.Cells(4,1).Value = "Account Type"
objExcel.Cells(4,2).Value = "Caption"
objExcel.Cells(4,3).Value = "Description"
objExcel.Cells(4,4).Value = "Disabled"
objExcel.Cells(4,5).Value = "Domain"
objExcel.Cells(4,6).Value = "FullName"
objExcel.Cells(4,7).Value = "InstallDate"
objExcel.Cells(4,7).Value = "LocalAccount"
objExcel.Cells(4,7).Value = "Lockout"
objExcel.Cells(4,7).Value = "Name"
objExcel.Cells(4,7).Value = "PasswordChangeable"
objExcel.Cells(4,7).Value = "PasswordExpires"
objExcel.Cells(4,7).Value = "PasswordRequired"
objExcel.Cells(4,7).Value = "SID"
objExcel.Cells(4,7).Value = "SIDType"
objExcel.Cells(4,7).Value = "Status"

x = 5
y = 1

   For Each objItem In colItems

      y1 = y

      objExcel.Cells(x,y1).Value = objItem.AccountType
      y1 = y1 + 1
      objExcel.Cells(x,y1).Value = objItem.Caption
      y1 = y1 + 1
      objExcel.Cells(x,y1).Value = objItem.Description
      y1 = y1 + 1
      objExcel.Cells(x,y1).Value = objItem.Disabled
      y1 = y1 + 1
      objExcel.Cells(x,y1).Value = objItem.Domain
      y1 = y1 + 1
      objExcel.Cells(x,y1).Value = objItem.FullName
      y1 = y1 + 1
      objExcel.Cells(x,y1).Value = WMIDateStringToDate(objItem.InstallDate)
      y1 = y1 + 1
      objExcel.Cells(x,y1).Value = objItem.LocalAccount
      y1 = y1 + 1
      objExcel.Cells(x,y1).Value = objItem.Lockout
      y1 = y1 + 1
      objExcel.Cells(x,y1).Value = objItem.Name
      y1 = y1 + 1
      objExcel.Cells(x,y1).Value = objItem.PasswordChangeable
      y1 = y1 + 1
      objExcel.Cells(x,y1).Value = objItem.PasswordExpires
      y1 = y1 + 1
      objExcel.Cells(x,y1).Value = objItem.PasswordRequired
      y1 = y1 + 1
      objExcel.Cells(x,y1).Value = objItem.SID
      y1 = y1 + 1
      objExcel.Cells(x,y1).Value = objItem.SIDType
      y1 = y1 + 1
      objExcel.Cells(x,y1).Value = objItem.Status

      x = x + 1 'go to the next Row
Next

objExcel.DisplayAlerts = False
Set objWorkbook = objExcel.ActiveWorkbook
objWorkbook.SaveAs strFile
objWorkbook.Close
objExcel.Quit

Function WMIDateStringToDate(dtmDate)
Report = Report & vbCrLf &  dtm:
    WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
    Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
    & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function

Wscript.Echo "Done"
internetjobs
above code will export all local users ( if you run in desktop ) and all domain users ( if you run in DC) to the excel file. Very Happy
internetjobs
hey..

copy and save above code as ****.vbs
Very Happy
dickyzin
How do I use it with Flash ActionScript 3?
dickyzin
I could also use it through Windows Web Sservices.
Diablosblizz
You might be able to get a program to make a XML file then get Flash AS3 (via URLLoader + URLRequest) to retrieve it.
Related topics
Webpage Design Programs
Windows xp service pack 2
Windows Service Pack 3 Preview, 100+ hotfixes
[Flash] ActionScript - Logical Error or Something else?
[news]Flash 9.0 :O
Need vb.net or Flash ActionScript Help!
Windows Vista
Flash ActionScript
Looking for flash/ActionScript jobs...700+ frih$
Flash/Actionscript.
little ActionScript 3.0 app
Flash ActionScript 2.0 Verical Animated Menu Problem
Learning Flash
Tutorial: How to create flash drop down menus and site navig
Reply to topic    Frihost Forum Index -> Computers -> Computer Problems and Support

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.