Skip to main content

API for SSO to individual email address rather than account

Comments

14 comments

  • Michael Turner
    Seems like there is.... I see logged sessions from specific email users. :
    Current Sessions (6) User Session Timestamp Browser Remote Host Authenticated Applications sixth@example.com [bdabnchciuc4tfu790fvjfm8q1] Thu, 18 May 2017 10:17:55 -0500 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 static-173-78-153-228.tampfl.fios.frontiernet.net [1.1.1.228] horde, imp, ingo, kronolith, turba, nag, mnemo, trean, timeobjects master_user [uiqeq53msntd67j8lul5vpdpi7] Thu, 01 Jun 2017 08:03:47 -0500 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 static-173-78-153-228.tampfl.fios.frontiernet.net [1.1.1.228] horde, imp, ingo, kronolith, turba, nag, mnemo, trean, timeobjects 345sgdfg@example.com [kjjqvok69lus5r547q8oh5qg06] Thu, 18 May 2017 10:21:59 -0500 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 static-173-78-153-228.tampfl.fios.frontiernet.net [1.1.1.228] horde, imp, ingo, kronolith, turba, nag, mnemo, trean, timeobjects
    0
  • Michael Turner
    looks like it is getabsbrowsedir
    0
  • Michael Turner
    and browseboxes but I am having difficulty using the paths returned. Any hints regarding how to reconcile full or relative paths to the webmail path?
    0
  • cPanelMichael
    Am I missing some technique that would allow me to place the user in a specific webmail account for a specific email once I generate the SSO session?

    Hello, Could you clarify how you achieve this outside of the API so we can verify the specific functionality you are seeking? Thank you.
    0
  • Michael Turner
    If you access the hosting account and navigate to the email, you can get a list of all the email addresses. Each email listed has a webmail link: Access Webmail Currently, I am only able to direct users to the hosting accounts master email account via webmail with API call create_user_session, using the URL returned. I'd like to send the user to the specific email (even though the user can navigate to the specific email from the master email account).
    0
  • Michael Turner
    The URL I am currently using to login users is:
    https://example.dnc.io:2096/cpsess0892882848/login/?session=username%3arUOiFCt6vTcb5BBv%3acreate_user_session%2cd0dff965711404b736e94dbaf475ba1d
    It works, in the sense that the user is taken to that account. But I want a specific account email address
    0
  • Michael Turner
    From within the hosting account, I go to email account... & get this part: 47315 Then click on 'more' and get this dropdown: 47319 The Access Webmail link is where I want to take my users directly. /Michael
    0
  • Michael Turner
    I am going to post some code and attempt to be clear regarding what I am attempting to accomplish. I want a link from my own web interface directly into a users webmail, accessing the users individual email address. user username with email addresses 001@example.com[/EMAIL], 002@example.com[/EMAIL], 003@example.com[/EMAIL], 004@example.com[/EMAIL]. I am able to reset the passwords for each of the 4 addresses, I am able to delete the email addresses and I am able to edit the disk quota for each address without sending the user to the cpanel webinterface. However, when I want to read the messages in each address, I have to access the master account and navigate to the specific address. I am looking for a technique to send users directly to their web address account to read their webmail for each specific account. In my attempt to direct users to their webmail, I have succeeded in using WHM API 1 function create_user_session to generate a session for use on the URL to identify users and allow them to access their webmail account. As I understand it, I need to use the cpsession##### generated in the create_user_session step to allow users to access directly from my host webinterface to the cpanel webmail interface.
    public function runquery($request="", $object=null, $server){ foreach($object as $key=>$value){ $params.="&".$key."=".$value; } $query="https://".$server.":2087/json-api/".$request."?api.version=1".$params; $this->curl = curl_init(); curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER,0); curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST,0); curl_setopt($this->curl, CURLOPT_HEADER,0); curl_setopt($this->curl, CURLOPT_RETURNTRANSFER,1); curl_setopt($this->curl,CURLOPT_VERBOSE,0); $header[0] = "Authorization: Basic " . base64_encode($whm_user.":".$whm_pass) . "\n\r"; curl_setopt($this->curl, CURLOPT_HTTPHEADER, $header); curl_setopt($this->curl, CURLOPT_URL, $query); $result = curl_exec($this->curl); $code = curl_getinfo($this->curl, CURLINFO_HTTP_CODE); if ($result == false){ $this->error("curl_exec threw error \"" . curl_error($this->curl) . "\" for $query"); } if($code<>200){ $this->error("Got response ".$code." from ".$server); } // new PHP code: $decoded_response = json_decode($result, true); $session_url = urldecode($decoded_response['data">['url">); // $session_url looks like:
    0
  • cPanelMichael
    Hello Michael, I'm not sure that functionality is supported. I recommend sending an email to integration [@] cpanel.net to see if one of our integration developers can help clarify if this is possible. Thank you.
    0
  • Sebastian Ng
    Dear @Michael Turner, Have you manage to get "host001.example.com:2096/cpsess0123456789/frontend/paper_lantern/mail/webmailform.html?user=user001@example.com&domain=example.com" this working? Give me some tips, i also in this. Sebastian Ng
    0
  • Michael Turner
    Yes, @Sebastian Ng I was given a solution by William Little at cpanel integrations. Here is his email: ----------------------------------------------------------------------------------------------------------------------------- Hi Michael, I can see our documentation for the 'create_user_session' API call doesn't actually show that email addresses can be passed, but when used with the 'webmaild' service parameter, email addresses are considered valid input, and will take you directly to the Email Addresses webmail interface:
    ==== # whmapi1 create_user_session user=testing@blue.com service=webmaild --- data: cp_security_token: /cpsess1236989019 expires: '1497891424' service: webmaild session: testing@blue.com:5a06TIlYlUxrOxcf:create_user_session,258f3793b015bc151e65a7550ebae7e7 url: https://host.example.com:2096/cpsess1236989019/login/?session=testing%40example2.com%3a5a06TIlYlUxrOxcf%3acreate_user_session%2c258f3793b015bc151e65a7550ebae7e7 metadata: command: create_user_session reason: Created session result: 1 version: 1 ====
    This may save you the trouble of trying to parse and splice out the correct URI from cPanel > Email > Access Webmail. Please let me know if this information wasn't helpful or if I didn't fully understand your issue. Thanks, -- William L. Technical Analyst cPanel, Inc. cPanel Forums ----------------------------------------------------------------------------------------------------------------------------- So, while manually creating the URL with email user does not work, the API does allow the passing of email (as user) when utilizing create_user_session with webmaild. Good luck! /Michael

    0
  • Sebastian Ng
    Dear @Michael Turner , Thank you, i manage to create the user session. I still facing some problem to open webmail. I tried 1. "/frontend/paper_lantern/mail/webmailform.html?user=user001@example.com&domain=example.com" fail. 2. "webmail/paper_lantern/index.html?login=1" this give me some indication does work properly not expected result. How did you manage to open webmail? Sorry to trouble you again. regards, Sebastian Ng
    0
  • Michael Turner
    No, that approach does not work. (IE manually creating a URL behind the session_id does not work.) What does work is to include the specific email for user -> "user=001@example.com" as a parameter when generating the session key with API function create_user_session (check manual: cpanel_jsonapi_user=$username; $data->cpanel_jsonapi_module="Email"; $return = create_user_session($data); // function create_user_session should have the curl code--available on cpanel site your query for the curl will look like this: $query= "
    0
  • Sebastian Ng
    Dear @Michael Turner, Thank you very much, i manage to get it get the link. The link i print it and copy to a new tab it works. Regards, Sebastian Ng
    0

Please sign in to leave a comment.