Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagephp
titleQuery by E-mail
linenumberstrue
<?php
// Login to the site and request the access token
$curl = curl_init('http://your-domain.com/restws/session/token');
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "restws_webservice:webservice_password"); // Your web service user credentials goes here.
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$token = curl_exec($curl);
// The token looks like "q71OBx05wtECfjA0KmXf6wiktewrywNhkMZv-OcfyOA%"
// #1 Verify if user exists by sending a GET request to the system, searching by user 'mail' attribute
$curl = curl_init("http://your-domain.com/user.json?mail=external_user@dlc-solutions.com");
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-CSRF-Token: $token", "Content-Type: application/json"));
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "restws_webservice:webservice_password"); //Your credentials goes here
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
 
$json = curl_exec($curl);
$response = json_decode($json);
 
// A list of users matching criteria will be returned. If this list is empty, a user does not exist in EthosCE with the given e-mail address.
$list = $response->list;

Successful Return

The response below describes information on a user with the e-mail address external_user@dlcdev.com, the most notable item being the uid 200.

Code Block
languagejs
linenumberstrue
{ 
  "self":"http://744.localhost/user?mail=external_user%40dlcdev.com",
  "first":"http://744.localhost/user?mail=external_user%40dlcdev.com\u0026page=0",
  "last":"http://744.localhost/user?mail=external_user%40dlcdev.com\u0026page=0",
  "list":[ 
    { 

      "uid":"200",
      "name":"external_user",
      "mail":"external_user@dlcdev.com",
      "url":"http://744.localhost/users/external_user",
      "edit_url":"http://744.localhost/user/200/edit",
      "last_access":"1469471140",
      "last_login":"1469469525",
      "created":"1459800968",
      "roles":[ 
        2
      ],
      "status":"1",
      "profile_profile":{ 
        "uri":"http://744.localhost/profile2/46",
        "id":"46",
        "resource":"profile2"
      },
      "uuid":"ba5bc8af-25d7-48de-bb54-87ae70ac33b5"
    }
  ]
}

 

 

Info
titleNote

uid is the unique Drupal identifier, which is different from the uuid. Uuid is the universal unique identifier, which is an internal identifier for the database system.

Query by client External ID

When a user is created via an SSO call, an authentication map entry is created, keying a uid to a client external ID. The external ID is a pre-determined key, being sent in the SSO call. It's format will vary per client install.

Code Block
languagephp
titleQuery by External ID
linenumberstrue
<?php
// Login to the site and request the access token
$curl = curl_init('http://your-domain.com/restws/session/token');
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "restws_webservice:webservice_password"); // Your web service user credentials goes here.
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$token = curl_exec($curl);
// The token looks like "q71OBx05wtECfjA0KmXf6wiktewrywNhkMZv-OcfyOA%"
 
// #1 Verify if user exists by sending a GET request to the system, searching by user 'nameauthname' attribute
$curl = curl_init("http://your-domain.com/authmap.json?nameauthname=external_user_500");
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-CSRF-Token: $token", "Content-Type: application/json"));
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "restws_webservice:webservice_password"); //Your credentials goes here
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
 
$json = curl_exec($curl);
$response = json_decode($json);
 
// A list of users matching criteria will be returned. If this list is empty, the user does not exist in EthosCE with the given e-mail address.
$list = $response->list;

Successful Return

A  successful return will provide an array in the list attribute, containing one item, with an array of user information.

Info
titleReturn Attributes

aid: The authentication ID key tracked by the database.

uid: The user's Drupal user ID.

authname: The user's unique identifier from the external system.

module: The module responsible for authenticating the user. This is usually the custom SSO implementation of the client.

Code Block
linenumberstrue
{"uri 
 
   "self":"https://your-domain.com/authmap?authname=14360896",
   "first":"httphttps://your-domain.com/authmap/200","id":"200","resource":"authmap"?authname=14360896\u0026page=0",
   "last":"https://your-domain.com/authmap?authname=14360896\u0026page=0",
   "list":[ 
 
      { 
 
         "aid":"2",
         "uid":"229",
         "authname":"14360896",
         "module":"client_sso"
      }
   ]
}

 

{  "self":"https://your-domain.com/authmap?authname=14360896",  "first":"https://your-domain.com/authmap?authname=14360896\u0026page=0",  "last":"https://your-domain.com/authmap?authname=14360896\u0026page=0",  "list":[    {      "aid":"2",      "uid":"229",      "authname":"14360896",      "module":"mayo_sso",      "feed_nid":null    }  ]}