Add LDAP service and seed task

This commit is contained in:
Râu Cao
2022-12-05 13:36:33 +01:00
parent 93d56f79d5
commit c3b9ff8b4a
3 changed files with 142 additions and 0 deletions

24
lib/tasks/ldap.rake Normal file
View File

@@ -0,0 +1,24 @@
namespace :ldap do
desc "Set up base entries for LDAP directory"
task seed: :environment do |t, args|
ldap = LdapService.new
ldap.delete_all_entries
ldap.add_entry "dc=kosmos,dc=org", {
dc: "kosmos", objectClass: ["top", "domain"]
}, true
ldap.add_entry "cn=users,dc=kosmos,dc=org", {
cn: "users", objectClass: ["top", "organizationalRole"]
}, true
ldap.add_organization "kosmos.org", "Kosmos", true
end
desc "List user domains/organizations"
task list_organizations: :environment do |t, args|
ldap = LdapService.new
orgs = ldap.fetch_organizations
puts orgs.inspect
end
end