You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2021/06/18 20:12:07 UTC
[whimsy] branch master updated: Version of secretary/ldap-names.cgi
for members
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 171f766 Version of secretary/ldap-names.cgi for members
171f766 is described below
commit 171f7664fce1c8f06ff6cb9af6ebccb161409065
Author: Sebb <se...@apache.org>
AuthorDate: Fri Jun 18 21:11:58 2021 +0100
Version of secretary/ldap-names.cgi for members
---
www/members/index.cgi | 1 +
www/members/ldap-namecheck.cgi | 149 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 150 insertions(+)
diff --git a/www/members/index.cgi b/www/members/index.cgi
index f89dadf..f99cfe8 100755
--- a/www/members/index.cgi
+++ b/www/members/index.cgi
@@ -32,6 +32,7 @@ MISC = {
'mentors.cgi' => "New Member mentoring program overview",
'board-attend.cgi' => "Director attendance statistics at board meetings",
'board-nominations.cgi' => "Board Member nominations cross-check - ensuring nominations get on the ballot, etc.",
+ 'ldap-namecheck.cgi' => "Crosscheck LDAP Names With Public Name from ICLAs",
'namediff.cgi' => "Crosscheck Members Names With ICLA records",
'mirror_check.cgi' => "ASF Distribution Mirror Check - is a mirror configured correctly",
'download_check.cgi' => "Verify an Apache project download page is configured correctly"
diff --git a/www/members/ldap-namecheck.cgi b/www/members/ldap-namecheck.cgi
new file mode 100755
index 0000000..de6d255
--- /dev/null
+++ b/www/members/ldap-namecheck.cgi
@@ -0,0 +1,149 @@
+#!/usr/bin/env ruby
+PAGETITLE = "Crosscheck LDAP Names With Public Name from ICLAs" # Wvisible:members
+$LOAD_PATH.unshift '/srv/whimsy/lib'
+
+# Check LDAP names: cn, sn, givenName
+#
+# givenName and sn should match the output from ASF::Person.ldap_name
+
+
+require 'whimsy/asf'
+require 'wunderbar/script'
+require 'ruby2js/filter/functions'
+
+_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 the result of ASF::Person.ldap_name; cn should match Public Name'
+ _br
+ _ 'The table below show the differences, if any.'
+ _br
+ _ 'If the cn does not match the public name, the cell is light grey'
+ _br
+ _ 'The Modify? columns show suggested fixes. If the name is non-italic then the suggestion is likely correct; italicised suggestions may be wrong/unnecessary.'
+ _br
+ _ 'The suggested name is considered correct if:'
+ _ul do
+ _li 'The existing field value matches the uid (never initialised) or the cn (single name)'
+ _li 'The existing field is missing'
+ _li 'AND there are no parts of the cn unused'
+ end
+
+ # prefetch LDAP data
+ people = ASF::Person.preload(%w(uid cn sn givenName loginShell))
+ matches = 0
+ badGiven = 0
+ badSN = 0
+
+ # prefetch ICLA data
+ ASF::ICLA.preload
+
+ _table do
+ # Must agree with columnNames below
+ _tr do
+ _th 'uid'
+ _th "iclas.txt public name"
+ _th 'cn'
+ _th 'givenName'
+ _th 'Modify to?'
+ _th 'sn'
+ _th 'Modify to?'
+ _th 'Unused names'
+ end
+
+ people.sort_by(&:name).each do |p|
+ next if p.banned?
+ next if p.name == 'apldaptest'
+
+ given = p.givenName rescue '---' # some entries have not set this up
+
+ parse = ASF::Person.ldap_name(p.cn)
+ new_given = parse['givenName']
+ new_sn = parse['sn']
+ unused = parse['unused']
+ _initials = parse['initials']
+
+ givenOK = (new_given == given)
+ badGiven += 1 unless givenOK
+
+ snOK = (new_sn == p.sn)
+ badSN += 1 unless snOK
+
+ icla = ASF::ICLA.find_by_id(p.uid)
+ public_name = icla.name rescue '?'
+
+ cnOK = (public_name == p.cn or public_name == '?') # don't check cn against missing public name
+ if givenOK and snOK and cnOK # all checks OK
+ matches += 1
+ next
+ end
+
+ _tr do
+ _td do
+ _a p.uid, href: '/roster/committer/' + p.uid
+ end
+ _td public_name
+ if p.cn == public_name
+ _td p.cn
+ else
+ _td bgcolor: 'lightgrey' do
+ _ p.cn
+ end
+ end
+ _td do
+ if givenOK
+ _ given
+ else
+ _em given
+ end
+ end
+ _td! copyAble: 'true' do
+ if givenOK
+ _ ''
+ else
+ if unused.size == 0 and (given == p.uid or given == '---' or given == p.cn)
+ _ new_given # likely to be correct
+ else
+ _em new_given # less likely
+ end
+ end
+ end
+ _td do
+ if snOK
+ _ p.sn
+ else
+ _em p.sn
+ end
+ end
+ _td! copyAble: 'true' do
+ if snOK
+ _ ''
+ else
+ if unused.size == 0 and (p.sn == p.uid or p.sn == p.cn)
+ _ new_sn
+ else
+ _em new_sn
+ end
+ end
+ end
+ _td unused.join(' ')
+ end
+ end
+ end
+
+ _p do
+ _ "Total: #{people.size} Matches: #{matches} GivenBad: #{badGiven} SNBad: #{badSN}"
+ end
+
+ end
+
+end
\ No newline at end of file