#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    5
    Rep Power
    0

    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
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,129
    Rep Power
    9398
    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).
  4. #3
  5. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    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.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    5
    Rep Power
    0
    Is there any mechanism from microsoft that allows to authenticate to the exchange, using SSO or token and php?
  8. #5
  9. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    We don't know, is there? Google (or bing, I guess) is much more likely to answer that than we are.
    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.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    5
    Rep 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($chCURLOPT_URL$this->url "/exchange/");
                
    curl_setopt($chCURLOPT_CONNECTTIMEOUT5);
                
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
                
    curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue);
                
    curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
                
    curl_setopt($chCURLOPT_COOKIEJAR$this->tmpfile);
                
    curl_setopt($chCURLOPT_COOKIEFILE$this->tmpfile);
                
    curl_setopt($chCURLOPT_USERAGENT"Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061024 BonEcho/2.0");
                
    curl_setopt($chCURLOPT_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($chCURLOPT_HTTPHEADER$headers);

                
    $html curl_exec($ch);
                
    curl_close($ch);

                
    $ch curl_init();
                
    curl_setopt($chCURLOPT_URL$this->url "/exchweb/bin/auth/owaauth.dll");
                
    curl_setopt($chCURLOPT_CONNECTTIMEOUT5);
                
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
                
    curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue);
                
    curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
                
    curl_setopt($chCURLOPT_COOKIEJAR$this->tmpfile);
                
    curl_setopt($chCURLOPT_COOKIEFILE$this->tmpfile);
                
    curl_setopt($chCURLOPT_USERAGENT"Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061024 BonEcho/2.0");
                
    curl_setopt($chCURLOPT_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($chCURLOPT_HTTPHEADER$headers);

                
    curl_setopt($chCURLOPT_POSTtrue);
                 
    curl_setopt($chCURLOPT_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($chCURLOPT_URL$this->url $url);
                
    curl_setopt($chCURLOPT_CONNECTTIMEOUT5);
                
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
                
    curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue);
                
    curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
                
    curl_setopt($chCURLOPT_COOKIEJAR$this->tmpfile);
                
    curl_setopt($chCURLOPT_COOKIEFILE$this->tmpfile);
                
    curl_setopt($chCURLOPT_USERAGENT"Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1) Gecko/20061024 BonEcho/2.0");
                
    curl_setopt($chCURLOPT_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($chCURLOPT_HTTPHEADER$headers);

                
    $html curl_exec($ch);
                
    curl_close($ch);
                return 
    $html;
            }
        }
    ?>
  12. #7
  13. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    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.
    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.
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    5
    Rep Power
    0
    thanks, i will continue to search if it is any solution to my problem

IMN logo majestic logo threadwatch logo seochat tools logo