none
'Unspecied Error' when changing client SCCM site code from classic ASP page

    Question

  • I have the following code which works perfectly well in vbs form:

    <%

    ' Provide the needed configuration information here.
    Const SCCM_USERNAME="DOMAIN\WFTWMI"
    Const SCCM_PASSWORD="Passw0rd"

    if Request("bSetID") <> "" Then

    Set objLocator = CreateObject("WbemScripting.SWbemLocator")
    strSCCMClient = Request("txtComputerSetID")                         'Client Computer Name
    Set oNet = CreateObject("WScript.Network")

    ' Code is running server side - run with credentials if not local :

    If UCase(strSCCMClient) = UCase(oNet.ComputerName) Then
     Set objSMS = objLocator.ConnectServer(strSCCMClient, "root/ccm")
    Else
     Set objSMS = objLocator.ConnectServer(strSCCMClient, "root/ccm",SCCM_USERNAME,SCCM_PASSWORD)
    End If

    Set oInstance = objSMS.Get("SMS_Client")

    set oParams = oInstance.Methods_.Item("SetAssignedSite").inParameters.SpawnInstance_()

    oParams.sSiteCode = Request("txtID")    ' Site code to change client machine to

    objSMS.ExecMethod "SMS_Client", "SetAssignedSite", oParams  ' This line gives the 'unspecied error' message

    End If
    %>

    There is a pause of a second or two before the error message, so it's trying to do something and as I say. it works fine if I was to translate this into a vbscript. Any ideas?

    Friday, June 17, 2011 4:24 PM

Answers

  • I'm sure there is a way around this problem!

    You might be right, but as I mentioned, your scenario is pretty specific. You will probably need to ask about this in an SCCM forum.

    Bill

    Saturday, June 18, 2011 2:27 PM

All replies

  • Hi,

    As I understand it, classic ASP is deprecated and embedded ASP scripts in HTML pages run in a completely different security context than WSH scripts. Your other difficulty is that probably not many people are trying to combine the two. So probably the short answer to your question is "don't do that" (i.e., don't run your script from an ASP page). The reason is that you are asking a very environment-specific question that combines different areas of expertise (ASP security alongside SCCM).

    Bill

    Friday, June 17, 2011 6:01 PM
  • I am going to take a stab at this one, however, I don't use SMS or SCCM.

    One statement you made:

    "...it works fine if I was to translate this into a VBScript."

    I am assuming you mean use the same code in a .vbs file running under your or a service account context.  This would indicate to me that the account running your ASP page does not have the proper permissions to execute the ExecMethod() call.  In my experience, this is by design so that the web process that is executing the code cannot reach across to other machines and wreak havoc with unintended consequences.

    If this is in a protected area (i.e. non-public facing website), you could try to change the credentials running the ASP process and use one that works when you use the VBS file.  At least that will tell you if that is where the problem lies.  This is the way I would test if I were in your shoes.  (Of course, I would set it back to a more secure setting and find an alternate method to code it also.)


    Jonathan Tyler
    http://powershellreflections.wordpress.com
    Follow Me On Twitter
    Friday, June 17, 2011 6:01 PM
  • Well I've got plenty of other pages working which directly access and update SCCM with no problem. Also I have code in the script which makes it run under the user coontext, which I know works because I was getting 'access denied' errors before I started using it. I'm not saying this definitely isn't the problem, but I don't get errors to this effect any more. It is of course an intranet site so I have no problem with using domain credentials (which have admin privileges on my test machine).

    I'm sure there is a way around this problem!

    Friday, June 17, 2011 6:49 PM
  • I'm sure there is a way around this problem!

    You might be right, but as I mentioned, your scenario is pretty specific. You will probably need to ask about this in an SCCM forum.

    Bill

    Saturday, June 18, 2011 2:27 PM
  • oParams.sSiteCode objSMS.ExecMethod "SMS_Client", "SetAssignedSite", oParams  ' This line gives the 'unspecied error' message

    There is a pause of a second or two before the error message, so it's trying to do something and as I say. it works fine if I was to translate this into a vbscript. Any ideas?


    Please give us the number reported with teh error.  If it is not in the log thne trap and output it.

    On Error Resume Next

    oParams.sSiteCode objSMS.ExecMethod "SMS_Client", "SetAssignedSite", oParams  ' This line gives the 'unspecied error' message

    If Err.Number <> 0 Then

       ' output error to error page with error number.

     


    jv
    Saturday, June 18, 2011 5:06 PM
  • The number is -2147467259 which again, I believe is fairly generic.
    Monday, June 20, 2011 10:06 AM
  • Hi,

    -2147467259 (signed) is (unsigned DWORD) 0x80004005, which as you have noted is non-specific.

    As I see it, you have two problems. 1) Embedded ASP scripts in HTML pages run in a different security context than WSH scripts. 2) Probably not many people are trying to combine SCCM automation with ASP. So probably the short answer to your question is "don't do that" (i.e., don't run your script from an ASP page). The reason is that you are asking a very environment-specific question that combines different areas of expertise (ASP security and SCCM).

    Bill
    Monday, June 20, 2011 5:24 PM