getHierarchy_v2
Retrieves the hierarchy of a specified Rescue account. Unlike the getUser and getGroup methods, the getHierarchy_v2 method retrieves information about any type of Rescue node.
Changes in Version 2 of getHierarchy
- filteroffline has been added as new input parameter.
Input Parameters
Element | Description |
---|---|
isnode | The returned set is a node or the complete
hierarchy. Optional.
The possible value are as follows:
|
node | Contains the ID of the node if the value of the isnode parameter is true. Optional. |
filteroffline | Filters offline technicians from the
hierarchy. Optional.
The possible value are as follows:
Note: This parameter does not filter offline nodes that are
not technicians.
|
authcode | The secret authentication code that is used to authenticate the user without logging in to Rescue. Optional. |
Output
OK NodeID:337364 ParentID:337363 Name:Technician Group1 Email: Description:
Status:Offline Type:TechnicianGroup
NodeID: ID of the Rescue node ParentID: ID of the node's parent node Name: Name of the node Email: If available, the email address of the node Description: Description of the node Status: Status of the node as listed below Type: Type of the node as listed below
The following node statuses are available:
- Disabled
- Offline
- Online
- Busy
- Away
The following node types are available:
- Root
- Masteradministrators
- Administrators
- Technicians
- AdministratorGroup
- TechnicianGroup
- Masteradministrator
- Administrator
- Technician
- AdministratorLink
- AdministratorGroupLink
- Channel
Return Values
Displayed Return Value | Description |
---|---|
ERROR | An unspecified error occurred, such as timeout. |
OK | Retrieving the properties of the currently logged-in user's account succeeded. |
NOTLOGGEDIN | Retrieving information failed because the user is no longer logged in. |
INVALIDPARAM_ISNODE | The isnode parameter is incorrect. |
INVALIDPARAM_NODE | The isnode parameter is set to true and the node parameter is incorrect. |
INVALID_SECRETAUTHCODE | The secret authentication code for the user is invalid. |
USER_DELETED_OR_DISABLED | The user is deleted or disabled. |
HAS_NO_RIGHT | The specified user (node) does not have sufficient rights to retrieve the hierarchy of the Rescue account. |
Sample Code
The following are examples for using the getHierarchy_v2 method that you can call in your environment.
HTTP GET
https://secure.logmeinrescue.com/API/getHierarchy_v2.aspx?isnode=true&node=337364
&filteroffline=true&authcode=4ahx...80u0
HTTP POST
<form method="post" action="https://secure.logmeinrescue.com/API/getHierarchy_v2.aspx">
<input name="isnode" value="true">
<input name="node" value="337364">
<input name="filteroffline" value="true">
<input name="authcode" value="4ahx...80u0">
</form>
SOAP
For sample SOAP 1.1 and SOAP 1.2 request and response messages, visit https://secure.logmeinrescue.com/api/API.asmx?op=getHierarchy_v2.
PHP with SOAP
The example values shown must be replaced with actual values.
<?php
$soapclient = new SoapClient("https://secure.logmeinrescue.com/api/api.asmx?wsdl");
//define parameters
$loginparams = array (
'sEmail' => 'some@email.com',
'sPassword' => 'secretPassword'
);
$hierparams = array("" => "");
//login
$loginResult = $soapclient->login($loginparams);
//print the result
echo "<b>Login full response.</b><br />"; //formatting
print_r($loginResult);
echo "<br /><br />"; //formatting
//getHierarchy
$hierarchyResult = $soapclient->getHierarchy_v2($hierparams);
//print out the hierarchy full response
echo "<b>Hierarchy full response.</b><br />";
print_r($hierarchyResult);
echo "<br /><br />"; //formatting
//hierarchy array
$hierarchy = $hierarchyResult['aHierarchy'];
//nodes of the hierarchy
$nodes = $hierarchy["HIERARCHY"];
$numberofnodes = count($nodes);
echo "<b>Hierarchy on it's own.</b><br />";
print_r($hierarchy["HIERARCHY"]);
echo "<br /><br />"; //formatting
//now format the hierarchy
print_r("<b>" . "Formatted selection of hierarchy." . "</b>");
echo "<br />"; //formatting
echo "<table border =\"0\" cellspacing = \"5\">";
for ($iNodes = 0; $iNodes < $numberofnodes; $iNodes += 1)
{
print_r("<tr>");
print_r("<td>" . "Name: " . $nodes[$iNodes]["sName"] . "<br /></td>");
print_r("<td>" . "Email: <a href=\"mailto:" . $nodes[$iNodes]["sEmail"] . "\">"
. $nodes[$iNodes]["sEmail"] . "</a><br /></td>");
print_r("<td>" . "Role: " . $nodes[$iNodes]["eType"]) . "</td>";
print_r("</td>");
}
print_r("</table>");
?>
C# with HttpWebRequest
The example values shown must be replaced with actual values.
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
string sEndpoint = "https://secure.logmeinrescue.com/API/"; //add actionName.aspx? for
each action called
string sEmail = "some@email.com";
string sPwd = "secretPassword";
//sAuthCode is the return value of the requestAuthCode API call
string sAuthCode = "";
//set up the request
HttpWebRequest oReq = (HttpWebRequest)System.Net.WebRequest.Create(sEndpoint +
"login.aspx" + "?email=" + sEmail + "&pwd=" + sPwd);
//create a cookie container to store the cookies for this session
oReq.CookieContainer = new CookieContainer();
//get the response
HttpWebResponse oResp = (HttpWebResponse)oReq.GetResponse();
string sResp = new StreamReader(oResp.GetResponseStream()).ReadToEnd();
Response.Write("Login result: " + sResp + "<br />"); //You can customize the response
/*
//debug cookies
foreach (Cookie cook in oResp.Cookies)
{
Response.Write("Cookie:" + "<br />");
Response.Write("Name: " + cook.Name + " " + "Value: " + cook.Value + "<br />");
Response.Write("Domain: " + cook.Domain + "<br />");
Response.Write("Path: " + cook.Path + "<br />");
Response.Write("Port: " + cook.Port + "<br />");
Response.Write("Secure: " + cook.Secure + "<br />");
Response.Write("When issued: " + cook.TimeStamp + "<br />");
Response.Write("Expires: " + cook.Expires + " " + "Expired? " + cook.Expired + "<br />");
Response.Write("Don't save: " + cook.Discard + "<br />");
Response.Write("Comment: " + cook.Comment + "<br />");
Response.Write("Uri for comments: " + cook.CommentUri + "<br />");
Response.Write("Version: RFC " + cook.Version + "<br />");
// Show the string representation of the cookie.
Response.Write("String: " + cook.ToString());
}*/
//add cookies to cookie container
CookieContainer sessioncookie = oReq.CookieContainer;
//get the Hierarchy info
HttpWebRequest oReqHierarchy = (HttpWebRequest)System.Net.WebRequest.Create(sEndpoint
+ "getHierarchy_v2.aspx?isnode=true&node=337364&authcode=");
oReqHierarchy.CookieContainer = sessioncookie;
HttpWebResponse oRespHierarchy = (HttpWebResponse)oReqHierarchy.GetResponse();
string sRespHierarchy = new StreamReader(oRespHierarchy.GetResponseStream()).ReadToEnd();
Response.Write("getHierarchy_v2 result: " + sRespHierarchy + "<br />"); //You can customize
the response
%>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Rescue API Login Test</title>
</head>
<body>
</body>
</html>
C# with SOAP
The example values shown must be replaced with actual values.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using APIexamples.WebServiceClients;
namespace APIexamples
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string sEmail = "your@email.com"; //LogMeIn Rescue account email address
string sPwd = "secretpassword"; //LogMeIn Rescue account password
int iNode = 12345678; //Node ID of which to getHierarchy
HIERARCHY[] aHierarchy; //Setup empty array for getHierarchy_v2 response
DataTable dt = new DataTable(); //Setup DataTable for display
WebServiceClients.API proxy = new WebServiceClients.API();
proxy.CookieContainer = new CookieContainer();
//Login
WebServiceClients.loginRet oLogin = proxy.login(sEmail, sPwd);
Response.Write("Login: " + oLogin + "<br />");
//getHierarchy
WebServiceClients.getHierarchy_v2Ret ogetHierarchy_v2 = proxy.getHierarchy_v2(false,
iNode, out aHierarchy);
Response.Write(ogetHierarchy_v2.ToString());
//Bind return data to GridView
gridView1.DataSource = aHierarchy;
gridView1.DataBind();
}
}
}