Using PHP and LDAP to connect to Microsoft Office

2019-04-10 01:03发布

The company that I work for has migrated their local exchange to a hosted Office 365 solution. We are in the process of building out several externally(to our local network) hosted websites and would like to use LDAP authentication to build upon our existing, hosted user base.

Can anyone explain or point to some documentation of a way to use PHP and LDAP to connect to a remotely hosted AD (in this case Office 365) and authenticate users to it?

Thank you for your time and effort.

2条回答
Fickle 薄情
2楼-- · 2019-04-10 01:44

This is possible. Microsoft has recently released a Developer Preview for their Windows Azure cloud platform which functions like many other cloud computing services (Amazon, Pagoda Box, Heroku). Along with this new product is the ability for developed apps to leverage Single Sign On using your Office365 account credentials.

Here are a few articles that go over the PHP process:

  1. How to implement single sign-on with Windows Azure Active Directory - PHP Application
  2. Get Started with Windows Azure Active Directory

Notes:

  • Example one has its source in a git repo. This repo does not include a referenced .csproj file, so you will have to build the project with the included 3 source files. If I can do it, you can do it :).
  • It should also be noted that after Office365 authentication is complete and reroutes back to your app, it expects the return URL to be HTTPS, if it is not you will get an error (or at least I did).
查看更多
一夜七次
3楼-- · 2019-04-10 01:50

I had done a ldap authentication and other stuff using php this is the basic authentication make sure your DN is correct when you are trying to authenticate.

      define("LDAPSERVER","192.168.0.1"); // your server
      define("LDAPBINDDN","cn=Worker,dc=mlonline,");
      define("LDAPBINDPW","FakePassword");


        $ds=ldap_connect(LDAPSERVER);
        if($ds){
            try{
                    $bind=ldap_bind($ds,LDAPBINDDN,LDAPBINDPW);
                    if($bind){
                            //yeah authenticated
                    }else{
                        throw new Exception('Cannot Connect to server Authentication Failed');
                    }

            }catch(Exception $e){
                throw $e;
            }
        }else{
           throw new Exception('Server Down');
        }
查看更多
登录 后发表回答