douhuiwan5141 2014-10-18 20:34
浏览 113

vTiger CRM 6 + LDAP身份验证

I exploited the last days, but I wasn't able to find a real useful tutorial to intigrate LDAP Authentication into a vTiger CRM 6 (running on a Linux CentOS 6.5 distribution).

Any one experienced out here or some people who might share some useful manuals ?

  • 写回答

1条回答 默认 最新

  • doujiaozhao2489 2014-12-30 11:07
    关注

    Make directory into your crm destination:

    /var/www/html/crm/modules/Users/authTypes/

    Then, Download the ldap file from :

    http://downloads.sourceforge.net/project/adldap/adLDAP/adLDAP_4.0.4/adLDAP_4.0

    Just open and customize the settings for your needs. The following settings match those needed for a 2012R2 Active Directory.

    ...
    class adLDAP {
    
        /**
         * Define the different types of account in AD
         */
        const ADLDAP_NORMAL_ACCOUNT = 805306368;
        const ADLDAP_WORKSTATION_TRUST = 805306369;
        const ADLDAP_INTERDOMAIN_TRUST = 805306370;
        const ADLDAP_SECURITY_GLOBAL_GROUP = 268435456;
        const ADLDAP_DISTRIBUTION_GROUP = 268435457;
        const ADLDAP_SECURITY_LOCAL_GROUP = 536870912;
        const ADLDAP_DISTRIBUTION_LOCAL_GROUP = 536870913;
        const ADLDAP_FOLDER = 'OU';
        const ADLDAP_CONTAINER = 'CN';
    
        /**
        * The default port for LDAP non-SSL connections
        */
        const ADLDAP_LDAP_PORT = '389';
        /**
        * The default port for LDAPS SSL connections
        */
        const ADLDAP_LDAPS_PORT = '636';
    
        /**
        * The account suffix for your domain, can be set when the class is invoked
        *
        * @var string
        */
            protected $accountSuffix = "@cortoso.com";
    
        /**
        * The base dn for your domain
        *
        * If this is set to null then adLDAP will attempt to obtain this automatically from the rootDSE
        *
        * @var string
        */
            protected $baseDn = "";
    
        /**
        * Port used to talk to the domain controllers.
        *
        * @var int
        */
        protected $adPort = self::ADLDAP_LDAP_PORT;
        /**
        * Array of domain controllers. Specifiy multiple controllers if you
        * would like the class to balance the LDAP queries amongst multiple servers
        *
        * @var array
        */
        protected $domainControllers = array("dc01.cortoso.com", "dc02.cortoso.com");
    
        /**
        * Optional account with higher privileges for searching
        * This should be set to a domain admin account
        *
        * @var string
        * @var string
        */
        protected $adminUsername = "ldap-binduser";
        protected $adminPassword = "super-password";
    
        /**
        * AD does not return the primary group. http://support.microsoft.com/?kbid=321360
        * This tweak will resolve the real primary group.
        * Setting to false will fudge "Domain Users" and is much faster. Keep in mind though that if
        * someone's primary group is NOT domain users, this is obviously going to mess up the results
        *
        * @var bool
        */
            protected $realPrimaryGroup = false;
    
        /**
        * Use SSL (LDAPS), your server needs to be setup, please see
        * http://adldap.sourceforge.net/wiki/doku.php?id=ldap_over_ssl
        *
        * @var bool
        */
            protected $useSSL = false;
    
        /**
        * Use TLS
        * If you wish to use TLS you should ensure that $useSSL is set to false and vice-versa
        *
        * @var bool
        */
        protected $useTLS = true;
    
        /**
        * Use SSO
        * To indicate to adLDAP to reuse password set by the brower through NTLM or Kerberos
        *
        * @var bool
        */
        protected $useSSO = false;
    
        /**
        * When querying group memberships, do it recursively
        * eg. User Fred is a member of Group A, which is a member of Group B, which is a member of Group C
        * user_ingroup("Fred","C") will returns true with this option turned on, false if turned off
        *
        * @var bool
        */
            protected $recursiveGroups = true;
    
        ...
    ?>
    

    To be able to test adLDAP, it is much easier to write a small php sniplet than doing it directly with vTiger CRM. Just create a small adldap_test.php file, in the same directory where adLDAP.php resides, with following content:

    <?php
    
    require_once(dirname(FILE) . '/adLDAP.php');
    
    try {
        $adldap = new adLDAP();
    }
    
    catch (adLDAPException $e) {
        echo $e;
        exit();
    }
    $authUser = $adldap->authenticate('user-to-authenticate', 'users-password');
    if ($authUser == true) {
      echo "User authenticated successfully";
    }
    else {
      // getLastError is not needed, but may be helpful for finding out why:
      echo "
    ";
      echo $adldap->getLastError();
      echo "
    ";
    
      echo "User authentication unsuccessful";
    }
    
    echo "
    ";
    $result=$adldap->user()->infoCollection('ldap', array("*"));
    echo "User:
    ";
    echo $result->displayName;
    echo "Mail:
    ";
    echo $result->mail;
    
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分