April 22, 2005

How to get the current user SID in VBS

Here's a little vbscript to read the current user SID. I know it may have been quicker to use the ADSI WinNT provider instead of WMI but the WinNT provider doesn't return the user's SID in a humain readable form.


Function GetCurrentUserSID

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

Dim WshNetwork, objWMIService, colItems, objItem
Dim strUserDomain, strUserName

Set WshNetwork = WScript.CreateObject("WScript.Network")
strUserDomain = WshNetwork.UserDomain
strUserName = WshNetwork.UserName

Set objWMIService = GetObject("winmgmts:\\" & ComputerName & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount "&_
"WHERE (Domain="""&strUserDomain&""" AND Name="""&strUserName&""")", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
GetCurrentUserSID = objItem.SID
Next

Set colItems = Nothing
Set objWMIService = Nothing
Set WshNetwork=Nothing

End Function



The function should return a string that look like "S-1-5-21-1106520001-3238835185-2771580065-500". This is a SID.

How to Check A WordPress Site's PHP Version (& Upgrade Compatibility)

If you notice that your WordPress hosting provider is not running PHP 7, but has it available to its users, you may want to consider making ...