2016-04-06 136 views
0

我需要爲流星應用程序實現LDAP認證,因爲我們目前沒有LDAP服務器。使用openLDAP與流星JS

我可以在本地機器上使用OpenLDAP實施嗎?

我不知道了很多關於LDAP認證..所以我感謝所有幫助我可以..我實現這個下面提到的一段代碼,其我的朋友再次提供

 Template.ldapLogin.events({ 
     'submit #login-form': function (e) { 
      e.preventDefault(); 
      var form = $(e.target); 
      var username = form.find("#login-form-username").val(); 
      var password = form.find("#login-form-password").val(); 

      if (username === "admin") { 
      Meteor.loginWithPassword(username, password, function (error) { 
       if (! error && password === "admin") { 
       // Set switch to trigger alert to change password 
       Session.setPersistent("passChangePrompt", 1); 
       } 
      }); 
      } else { 
      Meteor.loginWithLDAP(username, password, 
       { dn: "uid=" + username + ",ou=<foo>,dc=<bar>,dc=<baz>,dc=<qux>" }, 
       function (error, success) { 
       if (error) { 
        console.log(error.reason); 
       } else { 
        FlowRouter.redirect('/'); 
       }; 
      }); 
      } 
     } 
     }); 
     Server: 

     Meteor.startup(function() { 
     LDAP_DEFAULTS.url = 'ldap://<ask your IT dude or gal>'; 
     LDAP_DEFAULTS.dn = 'ou=<foo>,dc=<bar>,dc=<baz>,dc=<qux>'; 
     LDAP_DEFAULTS.port = ''; 
     LDAP_DEFAULTS.searchResultsProfileMap = [ 
      { 
      resultKey: 'cn', 
      profileProperty: 'name' 
      } 
      ,{ 
      resultKey: 'mail', 
      profileProperty: 'phoneNumber' 
      } 
     ] 
     }); 

感謝

回答

0

是;您可以在本地開發機器上安裝並運行OpenLDAP。默認的LDAP端口是389,您尚未定義。所有取決於您的操作系統,您可能已打開端口。默認啓用TLS的端口爲689.

在處理Meteor接口之前,通過使用和LDAP客戶端BIND(即認證)來驗證LDAP服務器配置和LDAP認證,稱爲LDAP BIND。一旦你驗證了認證,它就是SMOP Meteor。