Ruby与LDAP或AD
有没有一种方法可以根据事实来决定和确认哪种方法更好、更容易与Ruby集成。LDAP还是ActiveDirectory?Ruby的LDAP绑定相当不错——虽然不太漂亮,但工作正常。当然,您可以作为LDAP服务器访问ActiveDirectory。我从未尝试过Ruby的任何ActiveDirectory绑定。ActiveDirectory是LDAP的一个实现。您可以使用gem与AD集成。我目前正在使用此gem从RHEL服务器连接到Windows域控制器Ruby与LDAP或AD,ruby,ldap,Ruby,Ldap,有没有一种方法可以根据事实来决定和确认哪种方法更好、更容易与Ruby集成。LDAP还是ActiveDirectory?Ruby的LDAP绑定相当不错——虽然不太漂亮,但工作正常。当然,您可以作为LDAP服务器访问ActiveDirectory。我从未尝试过Ruby的任何ActiveDirectory绑定。ActiveDirectory是LDAP的一个实现。您可以使用gem与AD集成。我目前正在使用此gem从RHEL服务器连接到Windows域控制器 gem install ruby-ldap
gem install ruby-ldap
我使用gem对工作中的ActiveDirectory服务器进行身份验证和查询。它工作得很好。下面是一些用于验证用户登录凭据并获取其全名的示例代码
def name_for_login( email, password )
email = email[/\A\w+/].downcase # Throw out the domain, if it was there
email << "@mycompany.com" # I only check people in my company
ldap = Net::LDAP.new(
host: 'ldap.mycompany.com', # Thankfully this is a standard name
auth: { method: :simple, email: email, password:password }
)
if ldap.bind
# Yay, the login credentials were valid!
# Get the user's full name and return it
ldap.search(
base: "OU=Users,OU=Accounts,DC=mycompany,DC=com",
filter: Net::LDAP::Filter.eq( "mail", email ),
attributes: %w[ displayName ],
return_result:true
).first.displayName.first
end
end
def name_用于登录(电子邮件、密码)
email=email[/\A\w+/]。downcase#如果存在域,则将其丢弃
电子邮件嗨jamin,我正在使用ruby ldap,在rails3应用程序中遇到了一个问题,你能看看这个问题吗?