The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
PHP5 - Microsoft 365 Authentication
Discuss Microsoft 365 Authentication in the PHP Development forum on Dev Shed. Microsoft 365 Authentication PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

February 6th, 2013, 09:57 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 5
Time spent in forums: 6 h 3 m 12 sec
Reputation Power: 0
|
|
|
PHP5 - Microsoft 365 Authentication
Hi
I'm trying to write a php script to login in my microsoft 365 account and redirect to the webpage
Someone can help me. How can I make that?
Thanks
|

February 6th, 2013, 12:19 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
|
You can't log someone into another site on their behalf (unless there's a specific mechanism built by the remote site to allow you to do that... which would be weird).
|

February 6th, 2013, 02:55 PM
|
 |
Likely to be eaten by a grue.
|
|
Join Date: Oct 2006
Location: Pennsylvania, USA
|
|
|
They don't have a "remember me" checkbox or something you can use? Seems like that would be easier.
__________________
HEY! YOU! Read the New User Guide and Forum Rules
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin
"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002
Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
|

February 7th, 2013, 03:08 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 5
Time spent in forums: 6 h 3 m 12 sec
Reputation Power: 0
|
|
|
Is there any mechanism from microsoft that allows to authenticate to the exchange, using SSO or token and php?
|

February 7th, 2013, 07:50 AM
|
 |
Likely to be eaten by a grue.
|
|
Join Date: Oct 2006
Location: Pennsylvania, USA
|
|
|
We don't know, is there? Google (or bing, I guess) is much more likely to answer that than we are.
|

February 7th, 2013, 10:48 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 5
Time spent in forums: 6 h 3 m 12 sec
Reputation Power: 0
|
|
I found a code:
But I don't know how to use it.
PHP Code:
<?php
$owa = new OWA('<username>', '<password>');
class OWA
{
public $username;
public $password;
public $url = "<outlook web access URL>";
public $domain = "<the part after the @ in your email address>";
private $tmpfile;
public function __construct($un, $pw)
{
$this->tmpfile = tempnam("/tmp", "owa");
$this->username = $un;
$this->password = $pw;
$this->login();
}
// Create a new curl session and login to OWA.
public function login()
{
@unlink($this->tmpfile);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->url . "/exchange/");
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, $this->tmpfile);
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->tmpfile);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061024 BonEcho/2.0");
curl_setopt($ch, CURLOPT_REFERER, $this->url . "/exchweb/bin/auth/owalogon.asp?url={$this->url}/exchange&reason=0");
$headers = array();
$headers[] = "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$headers[] = "Accept-Language: en-us,en;q=0.5";
$headers[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$html = curl_exec($ch);
curl_close($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->url . "/exchweb/bin/auth/owaauth.dll");
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, $this->tmpfile);
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->tmpfile);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061024 BonEcho/2.0");
curl_setopt($ch, CURLOPT_REFERER, $this->url . "/exchweb/bin/auth/owalogon.asp?url={$this->url}/exchange&reason=0");
$headers = array();
$headers[] = "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$headers[] = "Accept-Language: en-us,en;q=0.5";
$headers[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "destination=" . urlencode($this->url) . "%2Fexchange&flags=0&username=" . urlencode($this->username) . "&password=" . urlencode($this->password) . "&SubmitCreds=Log+On&trusted=0");
$html = curl_exec($ch);
curl_close($ch);
}
// After logging in, grab the contents of an OWA URL.
function get($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->url . $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, $this->tmpfile);
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->tmpfile);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061024 BonEcho/2.0");
curl_setopt($ch, CURLOPT_REFERER, $this->url . "/exchweb/bin/auth/owalogon.asp?url={$this->url}/exchange&reason=0");
$headers = array();
$headers[] = "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$headers[] = "Accept-Language: en-us,en;q=0.5";
$headers[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$html = curl_exec($ch);
curl_close($ch);
return $html;
}
}
?>
|

February 7th, 2013, 10:55 AM
|
 |
Likely to be eaten by a grue.
|
|
Join Date: Oct 2006
Location: Pennsylvania, USA
|
|
|
This code is for fetching pages from outlook web access. It does not log you in and redirect, it's for if you want to make your own calendar manager or something.
|

February 7th, 2013, 11:06 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 5
Time spent in forums: 6 h 3 m 12 sec
Reputation Power: 0
|
|
|
thanks, i will continue to search if it is any solution to my problem
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|