2016-04-06 138 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。