Changeset 121224
- Timestamp:
- 05/28/2009 07:21:15 PM (17 years ago)
- Location:
- simple-ldap-authentication/trunk
- Files:
-
- 3 added
- 5 edited
- 1 copied
-
extra-table.css (added)
-
extra-table.js (added)
-
languages/simple-ldap-authentication-ja.mo (modified) (previous)
-
languages/simple-ldap-authentication-ja.po (modified) (13 diffs)
-
languages/simple-ldap-authentication.pot (modified) (9 diffs)
-
readme.txt (modified) (1 diff)
-
screenshot-2.png (added)
-
screenshot-3.png (copied) (copied from simple-ldap-authentication/trunk/screenshot-2.png)
-
simple-ldap-authentication.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
simple-ldap-authentication/trunk/languages/simple-ldap-authentication-ja.po
r118102 r121224 3 3 "Project-Id-Version: シンプル LDAP 認証 1.0.1\n" 4 4 "Report-Msgid-Bugs-To: http://wordpress.org/tag/simple-ldap-authentication\n" 5 "POT-Creation-Date: 2009-05- 15 18:40+0900\n"6 "PO-Revision-Date: 2009-05- 15 18:43+0900\n"5 "POT-Creation-Date: 2009-05-29 03:34+0900\n" 6 "PO-Revision-Date: 2009-05-29 03:36+0900\n" 7 7 "Last-Translator: Yoshimitsu Mori <[email protected]>\n" 8 8 "Language-Team: Japanese <[email protected]>\n" … … 11 11 "Content-Transfer-Encoding: 8bit\n" 12 12 13 #. #-#-#-#-# simple-ldap-authentication.pot (Simple LDAP Authentication 1.0. 1) #-#-#-#-#13 #. #-#-#-#-# simple-ldap-authentication.pot (Simple LDAP Authentication 1.0.4) #-#-#-#-# 14 14 #. Plugin Name of an extension 15 #: simple-ldap-authentication.php: 7815 #: simple-ldap-authentication.php:80 16 16 msgid "Simple LDAP Authentication" 17 17 msgstr "シンプル LDAP 認証" 18 18 19 #: simple-ldap-authentication.php:1 4319 #: simple-ldap-authentication.php:103 20 20 msgid "" 21 21 "<strong>ERROR</strong>: LDAP user ID search filter is inacuurate. The filter " … … 25 25 "には '%user_id%' が含まれている必要があります。" 26 26 27 #: simple-ldap-authentication.php:1 5527 #: simple-ldap-authentication.php:115 28 28 #, php-format 29 29 msgid "<strong>ERROR</strong>: Cannot connect to '%s'." 30 30 msgstr "<strong>エラー</strong>:'%s' に接続できません。" 31 31 32 #: simple-ldap-authentication.php:1 6532 #: simple-ldap-authentication.php:125 33 33 msgid "" 34 34 "<strong>ERROR</strong>: LDAP bind failed. Either the LDAPS connection failed " … … 38 38 "たか、ログイン資格が間違っています。" 39 39 40 #: simple-ldap-authentication.php:1 6740 #: simple-ldap-authentication.php:127 41 41 msgid "<strong>ERROR</strong>: LDAP bind failed. Check the login credentials." 42 42 msgstr "" … … 44 44 "てください。" 45 45 46 #: simple-ldap-authentication.php: 23046 #: simple-ldap-authentication.php:190 47 47 msgid "" 48 48 "<strong>ERROR</strong>: This user exists in LDAP, but has not been granted " … … 52 52 "セスは許可されていません。" 53 53 54 #: simple-ldap-authentication.php:3 2954 #: simple-ldap-authentication.php:372 55 55 msgid "Simple LDAP Authentication Options" 56 56 msgstr "シンプル LDAP 認証の設定" 57 57 58 #: simple-ldap-authentication.php:3 3758 #: simple-ldap-authentication.php:380 59 59 msgid "LDAP Server" 60 60 msgstr "LDAP サーバ" 61 61 62 #: simple-ldap-authentication.php:3 4062 #: simple-ldap-authentication.php:383 63 63 msgid "LDAP Server (e.g. <code>ldap.example.net</code>)" 64 64 msgstr "LDAP サーバを指定してください。(例:<code>ldap.example.net</code>)" 65 65 66 #: simple-ldap-authentication.php:3 4466 #: simple-ldap-authentication.php:387 67 67 msgid "Use SSL connection with LDAP?" 68 68 msgstr "SSL 接続を使いますか?" 69 69 70 #: simple-ldap-authentication.php:3 4770 #: simple-ldap-authentication.php:390 71 71 msgid "If you use SSL connection or not, when LDAP connection." 72 72 msgstr "LDAP での接続時に SSL で通信を行うかを設定します。" 73 73 74 #: simple-ldap-authentication.php:3 5174 #: simple-ldap-authentication.php:394 75 75 msgid "Base DN" 76 76 msgstr "ベース DN" 77 77 78 #: simple-ldap-authentication.php:3 5478 #: simple-ldap-authentication.php:397 79 79 msgid "Base DN (e.g., <code>dc=example,dc=net</code>)" 80 80 msgstr "" … … 82 82 "code>)" 83 83 84 #: simple-ldap-authentication.php: 35884 #: simple-ldap-authentication.php:401 85 85 msgid "Bind DN" 86 86 msgstr "特権のないデータベースユーザ (バインド DN)" 87 87 88 #: simple-ldap-authentication.php: 36188 #: simple-ldap-authentication.php:404 89 89 msgid "Bind DN (e.g., <code>cn=proxyuser,dc=example,dc=net</code>)" 90 90 msgstr "" … … 92 92 "(例:<code>cn=proxyuser,dc=example,dc=net</code>)" 93 93 94 #: simple-ldap-authentication.php: 36594 #: simple-ldap-authentication.php:408 95 95 msgid "Bind Password" 96 96 msgstr "データベースログインアカウントのパスワード (バインド・パスワード)" 97 97 98 #: simple-ldap-authentication.php: 36898 #: simple-ldap-authentication.php:411 99 99 msgid "Password for database login account." 100 100 msgstr "" 101 101 "LDAP データベースにログインするのに使われるパスワードを入力してください。" 102 102 103 #: simple-ldap-authentication.php: 372103 #: simple-ldap-authentication.php:415 104 104 msgid "User ID Search Filter" 105 105 msgstr "ユーザ ID を検索する際のフィルタ" 106 106 107 #: simple-ldap-authentication.php: 375108 msgid "" 109 "LDAP filter for searching user ID (e.g., <code>(uid=%user_id%)</code>)<br />\n"107 #: simple-ldap-authentication.php:418 108 msgid "" 109 "LDAP filter for searching user ID (e.g., <code>(uid=%user_id%)</code>)<br />\n" 110 110 "This setting must contain <code>%user_id%</code> string." 111 111 msgstr "" 112 112 "ユーザ ID を検索するための LDAP フィルタを指定してください。(例:<code>(uid=" 113 "%user_id%)</code>)<br />\n"113 "%user_id%)</code>)<br />\n" 114 114 "この設定には、文字列 <code>%user_id%</code> が含まれている必要があります。" 115 115 116 #: simple-ldap-authentication.php: 380116 #: simple-ldap-authentication.php:423 117 117 msgid "Group Search Filter" 118 118 msgstr "グループを検索する際のフィルタ" 119 119 120 #: simple-ldap-authentication.php: 383121 msgid "" 122 "LDAP filter for searching group (e.g., <code>(cn=%group%)</code>)<br />\n"120 #: simple-ldap-authentication.php:426 121 msgid "" 122 "LDAP filter for searching group (e.g., <code>(cn=%group%)</code>)<br />\n" 123 123 "This setting must contain <code>%group%</code> string." 124 124 msgstr "" 125 125 "グループを検索するための LDAP フィルタを指定してください。(例:<code>(cn=%" 126 "group%)</code>)<br />\n"126 "group%)</code>)<br />\n" 127 127 "この設定には、文字列 <code>%group%</code> が含まれている必要があります。" 128 128 129 #: simple-ldap-authentication.php: 388129 #: simple-ldap-authentication.php:431 130 130 msgid "Group Member Attribute" 131 131 msgstr "グループメンバの属性" 132 132 133 #: simple-ldap-authentication.php: 391133 #: simple-ldap-authentication.php:434 134 134 msgid "LDAP attribute for group member (e.g., <code>memberuid</code>)" 135 135 msgstr "" … … 137 137 "<code>memberuid</code>)" 138 138 139 #: simple-ldap-authentication.php: 395139 #: simple-ldap-authentication.php:438 140 140 msgid "" 141 141 "Automatically create accounts for any and all users can authenticate to the " … … 143 143 msgstr "LDAP で認証された全てのユーザに対し自動的にアカウントを作成しますか?" 144 144 145 #: simple-ldap-authentication.php: 398145 #: simple-ldap-authentication.php:441 146 146 msgid "" 147 147 "Should a new user be created automatically if not already in the WordPress " … … 149 149 "Created users will obtain the role defined under "New User Default " 150 150 "Role" on the <a href=\"options-general.php\">General Options</a> page.\n" 151 "<br />\n"151 "<br />\n" 152 152 "This setting is separate from the Role Equivalent Groups option, below.\n" 153 "<br />\n"153 "<br />\n" 154 154 "<strong>Users with role equivalent groups will be created even if this " 155 155 "setting is turned off</strong> (because if you didn't want this to happen, " … … 160 160 "作成されたユーザは、<a href=\"options-general.php\">一般設定</a>ページの " 161 161 ""新規ユーザーのデフォルト権限" に沿った権限が与えられます。\n" 162 "<br />\n"162 "<br />\n" 163 163 "この設定は下にある自動グループ権限オプションとは独立して動作します。\n" 164 "<br />\n"164 "<br />\n" 165 165 "<strong>この設定がオフの場合でも、自動グループ権限に従ってユーザは作成されま" 166 166 "す。</strong>(この動作を望ましくないと思うのであれば、くだんの設定を空にして" 167 167 "おく必要があります。)" 168 168 169 #: simple-ldap-authentication.php:4 07169 #: simple-ldap-authentication.php:450 170 170 msgid "Default email domain" 171 171 msgstr "デフォルトの E-Mail ドメイン" 172 172 173 #: simple-ldap-authentication.php:4 10173 #: simple-ldap-authentication.php:453 174 174 msgid "" 175 175 "If the LDAP attribute 'mail' is blank, a user's email will be set to " … … 179 179 "定値\"になります。" 180 180 181 #: simple-ldap-authentication.php:4 14181 #: simple-ldap-authentication.php:457 182 182 msgid "Role Equivalent Groups" 183 183 msgstr "自動グループ権限" 184 184 185 #: simple-ldap-authentication.php:4 17186 msgid "" 187 "List of LDAP groups which correspond to WordPress user roles.<br />\n"185 #: simple-ldap-authentication.php:460 186 msgid "" 187 "List of LDAP groups which correspond to WordPress user roles.<br />\n" 188 188 "When a user is first created, his role will correspond to what is specified " 189 "here.<br />\n"189 "here.<br />\n" 190 190 "Format: <code>LDAP-Group=WordPress-Role;LDAP-Group=WordPress-Role;...</" 191 "code><br />\n"191 "code><br />\n" 192 192 "E.g., <code>Soc-Faculty=faculty</code> or <code>Faculty=faculty;" 193 "Students=subscriber</code><br />\n"193 "Students=subscriber</code><br />\n" 194 194 "A user will be created based on the first math, from left to right, so you " 195 "should obviously put the more powerful groups first.<br />\n"195 "should obviously put the more powerful groups first.<br />\n" 196 196 "NOTE: WordPress stores roles as lower case ( Faculty is stored as faculty )" 197 "<br />\n"197 "<br />\n" 198 198 "ALSO NOTE: LDAP groups are case-sensitive" 199 199 msgstr "" 200 "WordPress ユーザ権限に対応する LDAP グループをリストアップしてください。<br /"200 "WordPress ユーザ権限に対応する LDAP グループをリストアップしてください。<br /" 201 201 ">\n" 202 202 "ユーザが最初に作成される際、そのユーザの権限はここで指定される該当の物になり" 203 "ます。<br />\n"203 "ます。<br />\n" 204 204 "フォーマット:<code>LDAPグループ=WordPress権限;LDAPグループ=WordPress権限;..." 205 "</code><br />\n"205 "</code><br />\n" 206 206 "例:<code>Soc-Faculty=faculty</code> もしくは <code>Faculty=faculty;" 207 "Students=subscriber</code><br />\n"207 "Students=subscriber</code><br />\n" 208 208 "ユーザは左から右に向けて処理された最初の一致条件に基づき作成されるため、もっ" 209 "とも権限の強いグループを先に書くべきです。<br />\n"209 "とも権限の強いグループを先に書くべきです。<br />\n" 210 210 "注:WordPress は権限を小文字で保存します。(Faculty は faculty として保存され" 211 "ます)<br />\n"211 "ます)<br />\n" 212 212 "注:LDAP のグループは大文字小文字を区別します。" 213 214 #: simple-ldap-authentication.php:476 215 msgid "Role Equivalent Groups Editor" 216 msgstr "自動グループ権限エディタ" 217 218 #: simple-ldap-authentication.php:480 219 msgid "LDAP Group" 220 msgstr "LDAP グループ" 221 222 #: simple-ldap-authentication.php:481 223 msgid "WordPress Role" 224 msgstr "WordPress 権限" 213 225 214 226 #. Plugin URI of an extension -
simple-ldap-authentication/trunk/languages/simple-ldap-authentication.pot
r118102 r121224 7 7 msgid "" 8 8 msgstr "" 9 "Project-Id-Version: Simple LDAP Authentication 1.0. 1\n"9 "Project-Id-Version: Simple LDAP Authentication 1.0.4\n" 10 10 "Report-Msgid-Bugs-To: http://wordpress.org/tag/simple-ldap-authentication\n" 11 "POT-Creation-Date: 2009-05- 15 18:40+0900\n"11 "POT-Creation-Date: 2009-05-29 03:34+0900\n" 12 12 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 13 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 17 17 "Content-Transfer-Encoding: 8bit\n" 18 18 19 #. #-#-#-#-# simple-ldap-authentication.pot (Simple LDAP Authentication 1.0. 1) #-#-#-#-#19 #. #-#-#-#-# simple-ldap-authentication.pot (Simple LDAP Authentication 1.0.4) #-#-#-#-# 20 20 #. Plugin Name of an extension 21 #: simple-ldap-authentication.php: 7821 #: simple-ldap-authentication.php:80 22 22 msgid "Simple LDAP Authentication" 23 23 msgstr "" 24 24 25 #: simple-ldap-authentication.php:1 4325 #: simple-ldap-authentication.php:103 26 26 msgid "" 27 27 "<strong>ERROR</strong>: LDAP user ID search filter is inacuurate. The filter " … … 29 29 msgstr "" 30 30 31 #: simple-ldap-authentication.php:1 5531 #: simple-ldap-authentication.php:115 32 32 #, php-format 33 33 msgid "<strong>ERROR</strong>: Cannot connect to '%s'." 34 34 msgstr "" 35 35 36 #: simple-ldap-authentication.php:1 6536 #: simple-ldap-authentication.php:125 37 37 msgid "" 38 38 "<strong>ERROR</strong>: LDAP bind failed. Either the LDAPS connection failed " … … 40 40 msgstr "" 41 41 42 #: simple-ldap-authentication.php:1 6742 #: simple-ldap-authentication.php:127 43 43 msgid "<strong>ERROR</strong>: LDAP bind failed. Check the login credentials." 44 44 msgstr "" 45 45 46 #: simple-ldap-authentication.php: 23046 #: simple-ldap-authentication.php:190 47 47 msgid "" 48 48 "<strong>ERROR</strong>: This user exists in LDAP, but has not been granted " … … 50 50 msgstr "" 51 51 52 #: simple-ldap-authentication.php:3 2952 #: simple-ldap-authentication.php:372 53 53 msgid "Simple LDAP Authentication Options" 54 54 msgstr "" 55 55 56 #: simple-ldap-authentication.php:3 3756 #: simple-ldap-authentication.php:380 57 57 msgid "LDAP Server" 58 58 msgstr "" 59 59 60 #: simple-ldap-authentication.php:3 4060 #: simple-ldap-authentication.php:383 61 61 msgid "LDAP Server (e.g. <code>ldap.example.net</code>)" 62 62 msgstr "" 63 63 64 #: simple-ldap-authentication.php:3 4464 #: simple-ldap-authentication.php:387 65 65 msgid "Use SSL connection with LDAP?" 66 66 msgstr "" 67 67 68 #: simple-ldap-authentication.php:3 4768 #: simple-ldap-authentication.php:390 69 69 msgid "If you use SSL connection or not, when LDAP connection." 70 70 msgstr "" 71 71 72 #: simple-ldap-authentication.php:3 5172 #: simple-ldap-authentication.php:394 73 73 msgid "Base DN" 74 74 msgstr "" 75 75 76 #: simple-ldap-authentication.php:3 5476 #: simple-ldap-authentication.php:397 77 77 msgid "Base DN (e.g., <code>dc=example,dc=net</code>)" 78 78 msgstr "" 79 79 80 #: simple-ldap-authentication.php: 35880 #: simple-ldap-authentication.php:401 81 81 msgid "Bind DN" 82 82 msgstr "" 83 83 84 #: simple-ldap-authentication.php: 36184 #: simple-ldap-authentication.php:404 85 85 msgid "Bind DN (e.g., <code>cn=proxyuser,dc=example,dc=net</code>)" 86 86 msgstr "" 87 87 88 #: simple-ldap-authentication.php: 36588 #: simple-ldap-authentication.php:408 89 89 msgid "Bind Password" 90 90 msgstr "" 91 91 92 #: simple-ldap-authentication.php: 36892 #: simple-ldap-authentication.php:411 93 93 msgid "Password for database login account." 94 94 msgstr "" 95 95 96 #: simple-ldap-authentication.php: 37296 #: simple-ldap-authentication.php:415 97 97 msgid "User ID Search Filter" 98 98 msgstr "" 99 99 100 #: simple-ldap-authentication.php: 375101 msgid "" 102 "LDAP filter for searching user ID (e.g., <code>(uid=%user_id%)</code>)<br />\n"100 #: simple-ldap-authentication.php:418 101 msgid "" 102 "LDAP filter for searching user ID (e.g., <code>(uid=%user_id%)</code>)<br />\n" 103 103 "This setting must contain <code>%user_id%</code> string." 104 104 msgstr "" 105 105 106 #: simple-ldap-authentication.php: 380106 #: simple-ldap-authentication.php:423 107 107 msgid "Group Search Filter" 108 108 msgstr "" 109 109 110 #: simple-ldap-authentication.php: 383111 msgid "" 112 "LDAP filter for searching group (e.g., <code>(cn=%group%)</code>)<br />\n"110 #: simple-ldap-authentication.php:426 111 msgid "" 112 "LDAP filter for searching group (e.g., <code>(cn=%group%)</code>)<br />\n" 113 113 "This setting must contain <code>%group%</code> string." 114 114 msgstr "" 115 115 116 #: simple-ldap-authentication.php: 388116 #: simple-ldap-authentication.php:431 117 117 msgid "Group Member Attribute" 118 118 msgstr "" 119 119 120 #: simple-ldap-authentication.php: 391120 #: simple-ldap-authentication.php:434 121 121 msgid "LDAP attribute for group member (e.g., <code>memberuid</code>)" 122 122 msgstr "" 123 123 124 #: simple-ldap-authentication.php: 395124 #: simple-ldap-authentication.php:438 125 125 msgid "" 126 126 "Automatically create accounts for any and all users can authenticate to the " … … 128 128 msgstr "" 129 129 130 #: simple-ldap-authentication.php: 398130 #: simple-ldap-authentication.php:441 131 131 msgid "" 132 132 "Should a new user be created automatically if not already in the WordPress " … … 134 134 "Created users will obtain the role defined under "New User Default " 135 135 "Role" on the <a href=\"options-general.php\">General Options</a> page.\n" 136 "<br />\n"136 "<br />\n" 137 137 "This setting is separate from the Role Equivalent Groups option, below.\n" 138 "<br />\n"138 "<br />\n" 139 139 "<strong>Users with role equivalent groups will be created even if this " 140 140 "setting is turned off</strong> (because if you didn't want this to happen, " … … 142 142 msgstr "" 143 143 144 #: simple-ldap-authentication.php:4 07144 #: simple-ldap-authentication.php:450 145 145 msgid "Default email domain" 146 146 msgstr "" 147 147 148 #: simple-ldap-authentication.php:4 10148 #: simple-ldap-authentication.php:453 149 149 msgid "" 150 150 "If the LDAP attribute 'mail' is blank, a user's email will be set to " … … 152 152 msgstr "" 153 153 154 #: simple-ldap-authentication.php:4 14154 #: simple-ldap-authentication.php:457 155 155 msgid "Role Equivalent Groups" 156 156 msgstr "" 157 157 158 #: simple-ldap-authentication.php:4 17159 msgid "" 160 "List of LDAP groups which correspond to WordPress user roles.<br />\n"158 #: simple-ldap-authentication.php:460 159 msgid "" 160 "List of LDAP groups which correspond to WordPress user roles.<br />\n" 161 161 "When a user is first created, his role will correspond to what is specified " 162 "here.<br />\n"162 "here.<br />\n" 163 163 "Format: <code>LDAP-Group=WordPress-Role;LDAP-Group=WordPress-Role;...</" 164 "code><br />\n"164 "code><br />\n" 165 165 "E.g., <code>Soc-Faculty=faculty</code> or <code>Faculty=faculty;" 166 "Students=subscriber</code><br />\n"166 "Students=subscriber</code><br />\n" 167 167 "A user will be created based on the first math, from left to right, so you " 168 "should obviously put the more powerful groups first.<br />\n"168 "should obviously put the more powerful groups first.<br />\n" 169 169 "NOTE: WordPress stores roles as lower case ( Faculty is stored as faculty )" 170 "<br />\n"170 "<br />\n" 171 171 "ALSO NOTE: LDAP groups are case-sensitive" 172 msgstr "" 173 174 #: simple-ldap-authentication.php:476 175 msgid "Role Equivalent Groups Editor" 176 msgstr "" 177 178 #: simple-ldap-authentication.php:480 179 msgid "LDAP Group" 180 msgstr "" 181 182 #: simple-ldap-authentication.php:481 183 msgid "WordPress Role" 172 184 msgstr "" 173 185 -
simple-ldap-authentication/trunk/readme.txt
r119748 r121224 77 77 78 78 1. The administration page under Settings -> Simple LDAP Authentication 79 2. This plugin supports i18n. Japanese example. 79 2. Role Equivalent Groups Editor in the option page. 80 3. This plugin supports i18n. Japanese example. -
simple-ldap-authentication/trunk/simple-ldap-authentication.php
r119677 r121224 2 2 /* 3 3 Plugin Name: Simple LDAP Authentication 4 Version: 1.0. 34 Version: 1.0.4 5 5 Plugin URI: http://redgecko.jp/wp/ldap_auth/ 6 6 Description: Allows WordPress to authenticate users through LDAP … … 43 43 add_action('check_passwords', array(&$this, 'generate_password'), 10, 3); 44 44 add_filter('show_password_fields', array(&$this, 'disable_password_fields')); 45 add_filter('plugin_action_links', array(&$this, 'add_link'), 10, 2); 45 46 $this->ldap_auth_domain = dirname(plugin_basename(__FILE__)); 46 47 } … … 76 77 PLUGINDIR.'/'.dirname(plugin_basename(__FILE__)).'/languages', 77 78 dirname(plugin_basename(__FILE__)).'/languages'); 78 if ( function_exists('add_options_page') ) 79 add_options_page(__('Simple LDAP Authentication', $this->ldap_auth_domain), __('Simple LDAP Authentication', $this->ldap_auth_domain), 9, __FILE__, array(&$this, '_display_options_page')); 80 } 81 82 function _user_in_group( $ldap, $username, $group ) { 83 $base_dn = get_option('LDAP_authentication_base_dn'); 84 $group_filter = get_option('LDAP_authentication_group_filter'); 85 $group_attr = strtolower(get_option('LDAP_authentication_group_attribute')); 86 $replace_count = 0; 87 $group_filter = str_replace('%group%', $group, $group_filter, &$replace_count); 88 if ( $replace_count == 0 ) { 89 if ( defined('WP_DEBUG') && ( true === WP_DEBUG ) ) 90 trigger_error('LDAP group search filter is mistaked.'); 91 return false; 92 } 93 if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) { 94 $result = @ldap_search($ldap, $base_dn, $group_filter, array($group_attr)); 95 } else { 96 trigger_error('Searching group in LDAP with \'' . $group_filter . '\' filter.'); 97 $result = ldap_search($ldap, $base_dn, $group_filter, array($group_attr)); 98 } 99 if ( $result === FALSE ) return false; 100 $members = @ldap_get_entries($ldap, $result); 101 $members = $members[0][$group_attr]; 102 return in_array($username, $members); 103 } 104 105 function _get_user_role_equiv( $ldap, $username ) { 106 $role_equiv_groups = get_option('LDAP_authentication_role_equivalent_groups'); 107 $role_equiv_groups = explode(';', $role_equiv_groups); 108 $user_role = ''; 109 foreach ( $role_equiv_groups as $whatever => $role_group ) { 110 if ( defined('WP_DEBUG') && ( true === WP_DEBUG ) ) 111 trigger_error('Trying \'' . $role_group . '\' rule.'); 112 $role_group = explode('=', $role_group); 113 if ( count($role_group) != 2 ) 114 continue; 115 $ldap_group = $role_group[0]; 116 $corresponding_role = $role_group[1]; 117 if ( $this->_user_in_group($ldap, $username, $ldap_group) ) { 118 $user_role = $corresponding_role; 119 break; 120 } 121 } 122 if ( defined('WP_DEBUG') && ( true === WP_DEBUG ) ) 123 trigger_error('User \'' . $username . '\' is assigned as \'' . $user_role . '\' role.'); 124 return $user_role; 79 if ( function_exists('add_options_page') ) { 80 $page = add_options_page(__('Simple LDAP Authentication', $this->ldap_auth_domain), __('Simple LDAP Authentication', $this->ldap_auth_domain), 9, __FILE__, array(&$this, '_display_options_page')); 81 add_action("admin_print_styles-$page", array(&$this, 'add_admin_custom_css')); 82 add_action("admin_print_scripts-$page", array(&$this, 'add_admin_script')); 83 } 125 84 } 126 85 … … 271 230 } 272 231 232 /* 233 * Add action link in the plugin page. 234 */ 235 function add_link($links, $file) { 236 static $this_plugin; 237 if ( !$this_plugin ) $this_plugin = plugin_basename(__FILE__); 238 239 if ( $file === $this_plugin ) { 240 $settings_link = '<a href="options-general.php?page=' . $this_plugin . '">' . _('Settings') . '</a>'; 241 array_unshift($links, $settings_link); 242 } 243 244 return($links); 245 } 246 247 /* 248 * Add custom style sheet to the admin page 249 */ 250 function add_admin_custom_css() { 251 $style = WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/extra-table.css'; 252 wp_register_style('ldap-auth-extra', $style, array('colors')); 253 wp_enqueue_style('ldap-auth-extra'); 254 } 255 256 /* 257 * Add custom script to the admin page 258 */ 259 function add_admin_script() { 260 $script = WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/extra-table.js'; 261 wp_register_script('ldap-auth-extra', $script, array('jquery-ui-dialog')); 262 wp_enqueue_script('ldap-auth-extra'); 263 } 273 264 274 265 /************************************************************* 275 266 * Functions 276 267 *************************************************************/ 268 269 /* 270 * Check the group includes the target user. 271 */ 272 function _user_in_group( $ldap, $username, $group ) { 273 $base_dn = get_option('LDAP_authentication_base_dn'); 274 $group_filter = get_option('LDAP_authentication_group_filter'); 275 $group_attr = strtolower(get_option('LDAP_authentication_group_attribute')); 276 $replace_count = 0; 277 $group_filter = str_replace('%group%', $group, $group_filter, &$replace_count); 278 if ( $replace_count == 0 ) { 279 if ( defined('WP_DEBUG') && ( true === WP_DEBUG ) ) 280 trigger_error('LDAP group search filter is mistaked.'); 281 return false; 282 } 283 if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) { 284 $result = @ldap_search($ldap, $base_dn, $group_filter, array($group_attr)); 285 } else { 286 trigger_error('Searching group in LDAP with \'' . $group_filter . '\' filter.'); 287 $result = ldap_search($ldap, $base_dn, $group_filter, array($group_attr)); 288 } 289 if ( $result === FALSE ) return false; 290 $members = @ldap_get_entries($ldap, $result); 291 $members = $members[0][$group_attr]; 292 return in_array($username, $members); 293 } 294 295 /* 296 * Get the user's group info from LDAP and return the WordPress role. 297 */ 298 function _get_user_role_equiv( $ldap, $username ) { 299 $role_equiv_groups = get_option('LDAP_authentication_role_equivalent_groups'); 300 $role_equiv_groups = explode(';', $role_equiv_groups); 301 $user_role = ''; 302 foreach ( $role_equiv_groups as $whatever => $role_group ) { 303 if ( defined('WP_DEBUG') && ( true === WP_DEBUG ) ) 304 trigger_error('Trying \'' . $role_group . '\' rule.'); 305 $role_group = explode('=', $role_group); 306 if ( count($role_group) != 2 ) 307 continue; 308 $ldap_group = $role_group[0]; 309 $corresponding_role = $role_group[1]; 310 if ( $this->_user_in_group($ldap, $username, $ldap_group) ) { 311 $user_role = $corresponding_role; 312 break; 313 } 314 } 315 if ( defined('WP_DEBUG') && ( true === WP_DEBUG ) ) 316 trigger_error('User \'' . $username . '\' is assigned as \'' . $user_role . '\' role.'); 317 return $user_role; 318 } 277 319 278 320 /* … … 374 416 <td> 375 417 <input type="text" name="LDAP_authentication_uid_filter" id="LDAP_authentication_uid_filter" value="<?php echo $uid_filter; ?>" /><br /> 376 <?php _e('LDAP filter for searching user ID (e.g., <code>(uid=%user_id%)</code>)<br />418 <?php _e('LDAP filter for searching user ID (e.g., <code>(uid=%user_id%)</code>)<br /> 377 419 This setting must contain <code>%user_id%</code> string.', $this->ldap_auth_domain); ?> 378 420 </td> … … 382 424 <td> 383 425 <input type="text" name="LDAP_authentication_group_filter" id="LDAP_authentication_group_filter" value="<?php echo $group_filter; ?>" /><br /> 384 <?php _e('LDAP filter for searching group (e.g., <code>(cn=%group%)</code>)<br />426 <?php _e('LDAP filter for searching group (e.g., <code>(cn=%group%)</code>)<br /> 385 427 This setting must contain <code>%group%</code> string.', $this->ldap_auth_domain); ?> 386 428 </td> … … 399 441 <?php _e('Should a new user be created automatically if not already in the WordPress database?<br /> 400 442 Created users will obtain the role defined under "New User Default Role" on the <a href="options-general.php">General Options</a> page. 401 <br />443 <br /> 402 444 This setting is separate from the Role Equivalent Groups option, below. 403 <br />445 <br /> 404 446 <strong>Users with role equivalent groups will be created even if this setting is turned off</strong> (because if you didn\'t want this to happen, you would leave that option blank.)'); ?> 405 447 </td> … … 408 450 <th scope="row"><label for="LDAP_authentication_default_email_domain"><?php _e('Default email domain', $this->ldap_auth_domain); ?></label></th> 409 451 <td> 410 <input type="text" name="LDAP_authentication_default_email_domain" id="LDAP_authentication_default_email_domain" value="<?php echo $email_domain; ?>" ><br />452 <input type="text" name="LDAP_authentication_default_email_domain" id="LDAP_authentication_default_email_domain" value="<?php echo $email_domain; ?>" /><br /> 411 453 <?php _e('If the LDAP attribute \'mail\' is blank, a user\'s email will be set to username@whatever-this-says', $this->ldap_auth_domain); ?> 412 454 </td> … … 416 458 <td> 417 459 <input type="text" name="LDAP_authentication_role_equivalent_groups" id="LDAP_authentication_role_equivalent_groups" value="<?php echo $role_equiv_groups; ?>" /><br /> 418 <?php _e('List of LDAP groups which correspond to WordPress user roles.<br />419 When a user is first created, his role will correspond to what is specified here.<br />420 Format: <code>LDAP-Group=WordPress-Role;LDAP-Group=WordPress-Role;...</code><br />421 E.g., <code>Soc-Faculty=faculty</code> or <code>Faculty=faculty;Students=subscriber</code><br />422 A user will be created based on the first math, from left to right, so you should obviously put the more powerful groups first.<br />423 NOTE: WordPress stores roles as lower case ( Faculty is stored as faculty )<br />460 <?php _e('List of LDAP groups which correspond to WordPress user roles.<br /> 461 When a user is first created, his role will correspond to what is specified here.<br /> 462 Format: <code>LDAP-Group=WordPress-Role;LDAP-Group=WordPress-Role;...</code><br /> 463 E.g., <code>Soc-Faculty=faculty</code> or <code>Faculty=faculty;Students=subscriber</code><br /> 464 A user will be created based on the first math, from left to right, so you should obviously put the more powerful groups first.<br /> 465 NOTE: WordPress stores roles as lower case ( Faculty is stored as faculty )<br /> 424 466 ALSO NOTE: LDAP groups are case-sensitive', $this->ldap_auth_domain); ?> 425 467 </td> 426 468 </tr> 427 469 </table> 470 <input type="hidden" name="default_role" id="default_role" value="<?php echo get_option('default_role'); ?>" /> 428 471 <p class="submit"> 429 472 <input type="submit" name="Submit" value="<?php _e('Save Changes'); ?>" /> … … 431 474 </form> 432 475 </div> 476 <div id="equivalent_dialog" title="<?php _e('Role Equivalent Groups Editor', $this->ldap_auth_domain); ?>" style="display: none" class="ui-widget"> 477 <table class="equivalent-table form-table"> 478 <thead> 479 <tr align="center" class="ui-widget-header"> 480 <th scope="col"><?php _e('LDAP Group', $this->ldap_auth_domain); ?></th> 481 <th scope="col"><?php _e('WordPress Role', $this->ldap_auth_domain); ?></th> 482 <th scope="col"></th> 483 </tr> 484 </thead> 485 <tbody> 486 <tr valign="top" style="display: none"> 487 <td> 488 <input type="text" /> 489 </td> 490 <td> 491 <select><?php wp_dropdown_roles(); ?></select> 492 </td> 493 <td> 494 <div class="submit"> 495 <input type="button" value="+" /> 496 <input type="button" value="-" /> 497 <input type="button" value="↑" /> 498 <input type="button" value="↓" /> 499 </div> 500 </td> 501 </tr> 502 </tbody> 503 </table> 504 </div> 433 505 <?php 434 506 }
Note: See TracChangeset
for help on using the changeset viewer.