This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 6d7e5425 Use ldap library bind
6d7e5425 is described below

commit 6d7e5425ad2c958ddf61cbbb5e26acc268331ef7
Author: Sebb <[email protected]>
AuthorDate: Thu Jan 5 15:01:13 2023 +0000

    Use ldap library bind
---
 www/secretary/workbench/views/actions/memapp.json.rb | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/www/secretary/workbench/views/actions/memapp.json.rb 
b/www/secretary/workbench/views/actions/memapp.json.rb
index 85d1c786..2511af61 100644
--- a/www/secretary/workbench/views/actions/memapp.json.rb
+++ b/www/secretary/workbench/views/actions/memapp.json.rb
@@ -86,23 +86,12 @@ task "update cn=member,ou=groups,dc=apache,dc=org in LDAP" 
do
 
   complete do
     if ASF.memberids.include? @availid
-      _transcript ["#@availid already in group member"]
+      _transcript ["#{@availid} already in group member"]
     else
-      ldap = ASF.init_ldap(true)
-      ldap.bind("uid=#{env.user},ou=people,dc=apache,dc=org",
-        env.password)
-
-      ldap.modify "cn=member,ou=groups,dc=apache,dc=org",
-        [LDAP.mod(LDAP::LDAP_MOD_ADD, 'memberUid', [@availid])]
-
-      log = ["LDAP mod add: #{ldap.err2string(ldap.err)} (#{ldap.err})"]
-      if ldap.err == 0
-        _transcript log
-      else
-        _backtrace log
+      ASF::LDAP.bind(env.user, env.password) do
+        # TODO there ought to be a library method to do this
+        ASF::LDAP.modify(ASF::Group['member'].dn, 
[ASF::Base.mod_add('memberUid', @availid)])
       end
-
-      ldap.unbind
     end
   end
 end

Reply via email to