5 Replies Latest reply on Mar 11, 2013 10:13 AM by jary.busato

    How to invoke a LANDesk MBSDK method using a HTTP POST including credentials

    Rookie

      I want to do an automatic MBSDK method.

      Therefore I need to include the username and the password in the HTTP request.

      Does anyone know what the format is how to do that?

       

      I tried http://USERNAME:PASSWORD@CORESERVER/MBSDKService/MsgSDK.asmx/AddComputerEx?deviceName=DEVICENAME&type=Computer&ipAddress=1.1.1.1&IPName=DEVICENAME&macAddress=AB-CD-EF-12-34-56&assetTag=HDV2LV1

      But that doesn't work.

       

      Any ideas?

        • 1. Re: How to invoke a LANDesk MBSDK method using a HTTP POST including credentials
          BlairK Apprentice

          Hi, what are you trying to call the web service from? Powershell, C# or something else?

          I have been writing custom integration apps for clients to link hardware manufacturers systems and LANDesk using the web services for some time. If you can be more specific I may be able to offer you some help. If using c# or powershell you would set up the credentials for the http post in the code before the post rather than pass them in the http path like you are doing.

          Happy to offer you help if you can be more specific.

          Blair

          • 2. Re: How to invoke a LANDesk MBSDK method using a HTTP POST including credentials
            Rookie

            I try to call the webservice from a service management application called TOPdesk.

             

            My goal is that as soon a device is created in TOPdesk this device is created in LANDesk as wel via a http request automatically.

             

            This application is written in Java Mango.

             

            If I want to do a http request to this software the code COMNAND&j_username=USERNAME&j_password=PASSWORD but that doesn't work either.

            • 3. Re: How to invoke a LANDesk MBSDK method using a HTTP POST including credentials
              Apprentice

              The easiest way would be write a little asp.net website consuming nativly the webservice and just bypass informations like mac or hostname by http post parameters via the asp.net to the LAndesk Web Services.

               

              In total this would be just 10-15 lines of code.

               

              Visual Studio express is free of charge and the internet is full of samples.

               

              in.Net the authentification would be handled like this:

               

                          WebserviceReferenceName.WebServiceListener ws = new WebserviceReferenceName.WebServiceListener();

                          CredentialCache cc = new System.Net.CredentialCache();

                          cc.Add(new Uri(ws.Url), "NTLM", new System.Net.NetworkCredential("username", "password", "domain));

                          ws.Credentials = cc;

               

              you could just run the asp.net page on your core and just call it like:

              http://yourcore/yourwebshare/wsproxy.aspx&Computername=pc01&MAC=000c29afe112

               

              life could be so easy

              Cheers Butti

              • 4. Re: How to invoke a LANDesk MBSDK method using a HTTP POST including credentials
                Catalysttgj Expert

                I'm beginning to work with Winbatch scripting to call the MBSDK routines using the POST method. It seems to be working to pass the username and password as part of the URL, but I am using the domain\user format for the username field. Dont know if that might make a difference here for you or not. I'm also not sure that the method i'm using is working in all cases. When i used this method to try to pull a list of all tasks, it didn't seem to be getting anything, but i've been able to schedule a provisioning template successfully, and many other routines seem to work this way as well.

                 

                This is example code (in bold) for winbatch that i'm using for testing. I'm new to the soap stuff, so there may be flaws with this:

                 

                ;function that gets called later

                #DEFINEFUNCTION GetSOAPresult (URL,type,text)

                          objXML = ObjectCreate("Microsoft.XMLHTTP")

                          objXML.open("POST",URL,"False")

                          objXML.setRequestHeader("Man", StrCat("POST ",URL," HTTP/1.1" ))

                          objXML.setRequestHeader("MessageType", "CALL")

                          objXML.setRequestHeader("Content-Type", type)

                          objXML.setRequestHeader("SOAPAction", "Soap_Action")

                          objXML.send(text)

                          ResponsePage = objXML.responseText

                          ObjectClose(objXML)

                 

                          return ResponsePage

                #ENDFUNCTION

                 

                ;real username and password removed to protect the...

                user="domain\username"

                pass="password"

                acct="%user%:%pass%"     ;this is just concatenation of the above two variables.

                 

                ;here i'm just setting up the text that needs to be passed with the particular routine. the following is to do a Schedule Provisioning routine.

                ;i'm targeting an LDMS query in this routine as well which is "Asset Corrections".

                ;note, i've hardcoded a templateid to get the right provsioning template. This would be a bad design for production purposes, as the id's change as the templates are edited. It would be neccessary to make a routine that gets all the templates, enumerate and select the proper id. What I found is that when you edit a template, and its id changes, the OLD id will still work! Even though its not really there in the console anymore. In other words, if you call this routine it will still run the older copy of the template that doesn't have the most current edits, which can be very confusing.

                data = "taskName=ROBO Asset Correction&templateId=524&StartTime=02/15/2013 03:00:00 PM&Targets=Asset Corrections&reserved="

                 

                ;the actual call to the function up above.

                provtask = GetSOAPresult("http://%acct%@LDMS-IMAGE/MBSDKService/MsgSDK.asmx/ScheduleProvisioning","application/x-www-form-urlencoded",data)

                 

                ;this line is just to put a message on the screen to show what happened.

                message("",provtask)

                 

                 

                Anyway, hopefully something here will help you along. Its in winbatch format but this is not much different tha AutoIt, or just about anything else. Should be pretty simple to translate to another script format. I am still concerned that this isn't working to pull a simple list of all the scheduled tasks for a given user, so i'm interested, if there's a better way to pass the username and password perhaps in the header? So, if BlairK could share something on that, it would be much appreciated!

                 

                Cheers,

                g;-)

                • 5. Re: How to invoke a LANDesk MBSDK method using a HTTP POST including credentials
                  jary.busato Apprentice

                  Ewald,

                  write an email to me. You'll find the address in my profile info.

                  I'll send you a file I hope will solve your problems.


                  Regards

                   

                  Jary