whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: Compare cn, sn, givenName
Date Sat, 28 Jul 2018 12:29:09 GMT
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 d7a28b3  Compare cn, sn, givenName
d7a28b3 is described below

commit d7a28b34295784de207f0760e9f6321cad02eaf0
Author: Sebb <sebb@apache.org>
AuthorDate: Sat Jul 28 13:29:07 2018 +0100

    Compare cn, sn, givenName
---
 www/index.html               |  1 +
 www/secretary/ldap-names.cgi | 81 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 82 insertions(+)

diff --git a/www/index.html b/www/index.html
index c52d060..4f114e4 100644
--- a/www/index.html
+++ b/www/index.html
@@ -184,6 +184,7 @@
                 <li><a href="secretary/ldap-check">LDAP members and owners checks
(may take a while to respond)</a></li>
                 <li><a href="secretary/memapp_check">Check members.txt against
members_apps</a></li>
                 <li><a href="secretary/public-names">Public names: LDAP vs icla.txt</a></li>
+                <li><a href="secretary/ldap-names">LDAP name check: compare cn,
sn, givenName</a></li>
                 <li><a href="secretary/response-time">Response time test</a></li>
               </ul>
             </div>
diff --git a/www/secretary/ldap-names.cgi b/www/secretary/ldap-names.cgi
new file mode 100755
index 0000000..6ab25a7
--- /dev/null
+++ b/www/secretary/ldap-names.cgi
@@ -0,0 +1,81 @@
+#!/usr/bin/env ruby
+
+=begin
+
+Check LDAP names: cn, sn, givenName
+
+Both givenName and sn should match part of cn
+
+=end
+
+$LOAD_PATH.unshift '/srv/whimsy/lib'
+
+require 'whimsy/asf'
+require 'wunderbar'
+
+_html do
+  _style %{
+    table {border-collapse: collapse}
+    table, th, td {border: 1px solid black}
+    td {padding: 3px 6px}
+    tr:hover td {background-color: #FF8}
+    th {background-color: #a0ddf0}
+  }
+
+  _h1 'LDAP people name checks'
+
+  _p do
+    _ 'LDAP sn and givenName must match part of cn'
+    _br
+    _ 'The table below show the differences, if any'
+  end
+
+  # prefetch LDAP data
+  people = ASF::Person.preload(%w(uid cn sn givenName))
+  matches = 0
+
+  _table do
+    _tr do
+      _th 'uid'
+      _th 'cn'
+      _th 'givenName'
+      _th 'sn'
+    end
+
+    people.sort_by(&:name).each do |p|
+      given = p.givenName rescue '---' # some entries have not set this up
+      givenOK = p.cn.include? given
+      snOK = p.cn.include? p.sn
+      if givenOK and snOK
+        matches += 1
+        next
+      end
+      _tr do
+        _td do
+          _a p.uid, href: '/roster/committee/' + p.uid
+        end
+        _td do
+          _ p.cn
+        end
+        _td do
+          if givenOK
+            _ given
+          else
+            _em given
+          end
+        end
+        _td do
+          if snOK
+            _ p.sn
+          else
+            _em p.sn
+          end
+        end
+      end
+    end
+  end
+
+  _p do
+    _ "Total: #{people.size} Matches: #{matches}"
+  end
+end
\ No newline at end of file


Mime
View raw message