@@ -59,72 +59,72 @@ |
||
59 | 59 | |
60 | 60 | <div id="ldapSettings"> |
61 | 61 | <ul> |
62 | - <li id="#ldapWizard1"><a href="#ldapWizard1"><?php p($l->t('Server'));?></a></li> |
|
63 | - <li id="#ldapWizard2"><a href="#ldapWizard2"><?php p($l->t('Users'));?></a></li> |
|
64 | - <li id="#ldapWizard3"><a href="#ldapWizard3"><?php p($l->t('Login Attributes'));?></a></li> |
|
65 | - <li id="#ldapWizard4"><a href="#ldapWizard4"><?php p($l->t('Groups'));?></a></li> |
|
66 | - <li class="ldapSettingsTabs"><a href="#ldapSettings-2"><?php p($l->t('Expert'));?></a></li> |
|
67 | - <li class="ldapSettingsTabs"><a href="#ldapSettings-1"><?php p($l->t('Advanced'));?></a></li> |
|
62 | + <li id="#ldapWizard1"><a href="#ldapWizard1"><?php p($l->t('Server')); ?></a></li> |
|
63 | + <li id="#ldapWizard2"><a href="#ldapWizard2"><?php p($l->t('Users')); ?></a></li> |
|
64 | + <li id="#ldapWizard3"><a href="#ldapWizard3"><?php p($l->t('Login Attributes')); ?></a></li> |
|
65 | + <li id="#ldapWizard4"><a href="#ldapWizard4"><?php p($l->t('Groups')); ?></a></li> |
|
66 | + <li class="ldapSettingsTabs"><a href="#ldapSettings-2"><?php p($l->t('Expert')); ?></a></li> |
|
67 | + <li class="ldapSettingsTabs"><a href="#ldapSettings-1"><?php p($l->t('Advanced')); ?></a></li> |
|
68 | 68 | </ul> |
69 | - <?php if(OCP\App::isEnabled('user_webdavauth')) { |
|
69 | + <?php if (OCP\App::isEnabled('user_webdavauth')) { |
|
70 | 70 | print_unescaped('<p class="ldapwarning">'.$l->t('<b>Warning:</b> Apps user_ldap and user_webdavauth are incompatible. You may experience unexpected behavior. Please ask your system administrator to disable one of them.').'</p>'); |
71 | 71 | } |
72 | - if(!function_exists('ldap_connect')) { |
|
72 | + if (!function_exists('ldap_connect')) { |
|
73 | 73 | print_unescaped('<p class="ldapwarning">'.$l->t('<b>Warning:</b> The PHP LDAP module is not installed, the backend will not work. Please ask your system administrator to install it.').'</p>'); |
74 | 74 | } |
75 | 75 | ?> |
76 | - <?php require_once(__DIR__ . '/part.wizard-server.php'); ?> |
|
77 | - <?php require_once(__DIR__ . '/part.wizard-userfilter.php'); ?> |
|
78 | - <?php require_once(__DIR__ . '/part.wizard-loginfilter.php'); ?> |
|
79 | - <?php require_once(__DIR__ . '/part.wizard-groupfilter.php'); ?> |
|
76 | + <?php require_once(__DIR__.'/part.wizard-server.php'); ?> |
|
77 | + <?php require_once(__DIR__.'/part.wizard-userfilter.php'); ?> |
|
78 | + <?php require_once(__DIR__.'/part.wizard-loginfilter.php'); ?> |
|
79 | + <?php require_once(__DIR__.'/part.wizard-groupfilter.php'); ?> |
|
80 | 80 | <fieldset id="ldapSettings-1"> |
81 | 81 | <div id="ldapAdvancedAccordion"> |
82 | - <h3><?php p($l->t('Connection Settings'));?></h3> |
|
82 | + <h3><?php p($l->t('Connection Settings')); ?></h3> |
|
83 | 83 | <div> |
84 | - <p><label for="ldap_configuration_active"><?php p($l->t('Configuration Active'));?></label><input type="checkbox" id="ldap_configuration_active" name="ldap_configuration_active" value="1" data-default="<?php p($_['ldap_configuration_active_default']); ?>" title="<?php p($l->t('When unchecked, this configuration will be skipped.'));?>" /></p> |
|
85 | - <p><label for="ldap_backup_host"><?php p($l->t('Backup (Replica) Host'));?></label><input type="text" id="ldap_backup_host" name="ldap_backup_host" data-default="<?php p($_['ldap_backup_host_default']); ?>" title="<?php p($l->t('Give an optional backup host. It must be a replica of the main LDAP/AD server.'));?>"></p> |
|
86 | - <p><label for="ldap_backup_port"><?php p($l->t('Backup (Replica) Port'));?></label><input type="number" id="ldap_backup_port" name="ldap_backup_port" data-default="<?php p($_['ldap_backup_port_default']); ?>" /></p> |
|
87 | - <p><label for="ldap_override_main_server"><?php p($l->t('Disable Main Server'));?></label><input type="checkbox" id="ldap_override_main_server" name="ldap_override_main_server" value="1" data-default="<?php p($_['ldap_override_main_server_default']); ?>" title="<?php p($l->t('Only connect to the replica server.'));?>" /></p> |
|
88 | - <p><label for="ldap_turn_off_cert_check"><?php p($l->t('Turn off SSL certificate validation.'));?></label><input type="checkbox" id="ldap_turn_off_cert_check" name="ldap_turn_off_cert_check" title="<?php p($l->t('Not recommended, use it for testing only! If connection only works with this option, import the LDAP server\'s SSL certificate in your %s server.', $theme->getName() ));?>" data-default="<?php p($_['ldap_turn_off_cert_check_default']); ?>" value="1"><br/></p> |
|
89 | - <p><label for="ldap_cache_ttl"><?php p($l->t('Cache Time-To-Live'));?></label><input type="number" id="ldap_cache_ttl" name="ldap_cache_ttl" title="<?php p($l->t('in seconds. A change empties the cache.'));?>" data-default="<?php p($_['ldap_cache_ttl_default']); ?>" /></p> |
|
84 | + <p><label for="ldap_configuration_active"><?php p($l->t('Configuration Active')); ?></label><input type="checkbox" id="ldap_configuration_active" name="ldap_configuration_active" value="1" data-default="<?php p($_['ldap_configuration_active_default']); ?>" title="<?php p($l->t('When unchecked, this configuration will be skipped.')); ?>" /></p> |
|
85 | + <p><label for="ldap_backup_host"><?php p($l->t('Backup (Replica) Host')); ?></label><input type="text" id="ldap_backup_host" name="ldap_backup_host" data-default="<?php p($_['ldap_backup_host_default']); ?>" title="<?php p($l->t('Give an optional backup host. It must be a replica of the main LDAP/AD server.')); ?>"></p> |
|
86 | + <p><label for="ldap_backup_port"><?php p($l->t('Backup (Replica) Port')); ?></label><input type="number" id="ldap_backup_port" name="ldap_backup_port" data-default="<?php p($_['ldap_backup_port_default']); ?>" /></p> |
|
87 | + <p><label for="ldap_override_main_server"><?php p($l->t('Disable Main Server')); ?></label><input type="checkbox" id="ldap_override_main_server" name="ldap_override_main_server" value="1" data-default="<?php p($_['ldap_override_main_server_default']); ?>" title="<?php p($l->t('Only connect to the replica server.')); ?>" /></p> |
|
88 | + <p><label for="ldap_turn_off_cert_check"><?php p($l->t('Turn off SSL certificate validation.')); ?></label><input type="checkbox" id="ldap_turn_off_cert_check" name="ldap_turn_off_cert_check" title="<?php p($l->t('Not recommended, use it for testing only! If connection only works with this option, import the LDAP server\'s SSL certificate in your %s server.', $theme->getName())); ?>" data-default="<?php p($_['ldap_turn_off_cert_check_default']); ?>" value="1"><br/></p> |
|
89 | + <p><label for="ldap_cache_ttl"><?php p($l->t('Cache Time-To-Live')); ?></label><input type="number" id="ldap_cache_ttl" name="ldap_cache_ttl" title="<?php p($l->t('in seconds. A change empties the cache.')); ?>" data-default="<?php p($_['ldap_cache_ttl_default']); ?>" /></p> |
|
90 | 90 | </div> |
91 | - <h3><?php p($l->t('Directory Settings'));?></h3> |
|
91 | + <h3><?php p($l->t('Directory Settings')); ?></h3> |
|
92 | 92 | <div> |
93 | - <p><label for="ldap_display_name"><?php p($l->t('User Display Name Field'));?></label><input type="text" id="ldap_display_name" name="ldap_display_name" data-default="<?php p($_['ldap_display_name_default']); ?>" title="<?php p($l->t('The LDAP attribute to use to generate the user\'s display name.'));?>" /></p> |
|
94 | - <p><label for="ldap_user_display_name_2"><?php p($l->t('2nd User Display Name Field'));?></label><input type="text" id="ldap_user_display_name_2" name="ldap_user_display_name_2" data-default="<?php p($_['ldap_user_display_name_2_default']); ?>" title="<?php p($l->t('Optional. An LDAP attribute to be added to the display name in brackets. Results in e.g. »John Doe ([email protected])«.'));?>" /></p> |
|
95 | - <p><label for="ldap_base_users"><?php p($l->t('Base User Tree'));?></label><textarea id="ldap_base_users" name="ldap_base_users" placeholder="<?php p($l->t('One User Base DN per line'));?>" data-default="<?php p($_['ldap_base_users_default']); ?>" title="<?php p($l->t('Base User Tree'));?>"></textarea></p> |
|
96 | - <p><label for="ldap_attributes_for_user_search"><?php p($l->t('User Search Attributes'));?></label><textarea id="ldap_attributes_for_user_search" name="ldap_attributes_for_user_search" placeholder="<?php p($l->t('Optional; one attribute per line'));?>" data-default="<?php p($_['ldap_attributes_for_user_search_default']); ?>" title="<?php p($l->t('User Search Attributes'));?>"></textarea></p> |
|
97 | - <p><label for="ldap_group_display_name"><?php p($l->t('Group Display Name Field'));?></label><input type="text" id="ldap_group_display_name" name="ldap_group_display_name" data-default="<?php p($_['ldap_group_display_name_default']); ?>" title="<?php p($l->t('The LDAP attribute to use to generate the groups\'s display name.'));?>" /></p> |
|
98 | - <p><label for="ldap_base_groups"><?php p($l->t('Base Group Tree'));?></label><textarea id="ldap_base_groups" name="ldap_base_groups" placeholder="<?php p($l->t('One Group Base DN per line'));?>" data-default="<?php p($_['ldap_base_groups_default']); ?>" title="<?php p($l->t('Base Group Tree'));?>"></textarea></p> |
|
99 | - <p><label for="ldap_attributes_for_group_search"><?php p($l->t('Group Search Attributes'));?></label><textarea id="ldap_attributes_for_group_search" name="ldap_attributes_for_group_search" placeholder="<?php p($l->t('Optional; one attribute per line'));?>" data-default="<?php p($_['ldap_attributes_for_group_search_default']); ?>" title="<?php p($l->t('Group Search Attributes'));?>"></textarea></p> |
|
100 | - <p><label for="ldap_group_member_assoc_attribute"><?php p($l->t('Group-Member association'));?></label><select id="ldap_group_member_assoc_attribute" name="ldap_group_member_assoc_attribute" data-default="<?php p($_['ldap_group_member_assoc_attribute_default']); ?>" ><option value="uniqueMember"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'uniqueMember')) p(' selected'); ?>>uniqueMember</option><option value="memberUid"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'memberUid')) p(' selected'); ?>>memberUid</option><option value="member"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'member')) p(' selected'); ?>>member (AD)</option><option value="gidNumber"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'gidNumber')) p(' selected'); ?>>gidNumber</option></select></p> <p><label for="ldap_dynamic_group_member_url"><?php p($l->t('Dynamic Group Member URL'));?></label><input type="text" id="ldap_dynamic_group_member_url" name="ldap_dynamic_group_member_url" title="<?php p($l->t('The LDAP attribute that on group objects contains an LDAP search URL that determines what objects belong to the group. (An empty setting disables dynamic group membership functionality.)'));?>" data-default="<?php p($_['ldap_dynamic_group_member_url_default']); ?>" /></p> |
|
101 | - <p><label for="ldap_nested_groups"><?php p($l->t('Nested Groups'));?></label><input type="checkbox" id="ldap_nested_groups" name="ldap_nested_groups" value="1" data-default="<?php p($_['ldap_nested_groups_default']); ?>" title="<?php p($l->t('When switched on, groups that contain groups are supported. (Only works if the group member attribute contains DNs.)'));?>" /></p> |
|
102 | - <p><label for="ldap_paging_size"><?php p($l->t('Paging chunksize'));?></label><input type="number" id="ldap_paging_size" name="ldap_paging_size" title="<?php p($l->t('Chunksize used for paged LDAP searches that may return bulky results like user or group enumeration. (Setting it 0 disables paged LDAP searches in those situations.)'));?>" data-default="<?php p($_['ldap_paging_size_default']); ?>" /></p> |
|
103 | - <p><label for="ldap_turn_on_pwd_change"><?php p($l->t('Enable LDAP password changes per user'));?></label><span class="inlinetable"><span class="tablerow left"><input type="checkbox" id="ldap_turn_on_pwd_change" name="ldap_turn_on_pwd_change" value="1" data-default="<?php p($_['ldap_turn_on_pwd_change_default']); ?>" title="<?php p($l->t('Allow LDAP users to change their password and allow Super Administrators and Group Administrators to change the password of their LDAP users. Only works when access control policies are configured accordingly on the LDAP server. As passwords are sent in plaintext to the LDAP server, transport encryption must be used and password hashing should be configured on the LDAP server.'));?>" /><span class="tablecell"><?php p($l->t('(New password is sent as plain text to LDAP)'));?></span></span> |
|
93 | + <p><label for="ldap_display_name"><?php p($l->t('User Display Name Field')); ?></label><input type="text" id="ldap_display_name" name="ldap_display_name" data-default="<?php p($_['ldap_display_name_default']); ?>" title="<?php p($l->t('The LDAP attribute to use to generate the user\'s display name.')); ?>" /></p> |
|
94 | + <p><label for="ldap_user_display_name_2"><?php p($l->t('2nd User Display Name Field')); ?></label><input type="text" id="ldap_user_display_name_2" name="ldap_user_display_name_2" data-default="<?php p($_['ldap_user_display_name_2_default']); ?>" title="<?php p($l->t('Optional. An LDAP attribute to be added to the display name in brackets. Results in e.g. »John Doe ([email protected])«.')); ?>" /></p> |
|
95 | + <p><label for="ldap_base_users"><?php p($l->t('Base User Tree')); ?></label><textarea id="ldap_base_users" name="ldap_base_users" placeholder="<?php p($l->t('One User Base DN per line')); ?>" data-default="<?php p($_['ldap_base_users_default']); ?>" title="<?php p($l->t('Base User Tree')); ?>"></textarea></p> |
|
96 | + <p><label for="ldap_attributes_for_user_search"><?php p($l->t('User Search Attributes')); ?></label><textarea id="ldap_attributes_for_user_search" name="ldap_attributes_for_user_search" placeholder="<?php p($l->t('Optional; one attribute per line')); ?>" data-default="<?php p($_['ldap_attributes_for_user_search_default']); ?>" title="<?php p($l->t('User Search Attributes')); ?>"></textarea></p> |
|
97 | + <p><label for="ldap_group_display_name"><?php p($l->t('Group Display Name Field')); ?></label><input type="text" id="ldap_group_display_name" name="ldap_group_display_name" data-default="<?php p($_['ldap_group_display_name_default']); ?>" title="<?php p($l->t('The LDAP attribute to use to generate the groups\'s display name.')); ?>" /></p> |
|
98 | + <p><label for="ldap_base_groups"><?php p($l->t('Base Group Tree')); ?></label><textarea id="ldap_base_groups" name="ldap_base_groups" placeholder="<?php p($l->t('One Group Base DN per line')); ?>" data-default="<?php p($_['ldap_base_groups_default']); ?>" title="<?php p($l->t('Base Group Tree')); ?>"></textarea></p> |
|
99 | + <p><label for="ldap_attributes_for_group_search"><?php p($l->t('Group Search Attributes')); ?></label><textarea id="ldap_attributes_for_group_search" name="ldap_attributes_for_group_search" placeholder="<?php p($l->t('Optional; one attribute per line')); ?>" data-default="<?php p($_['ldap_attributes_for_group_search_default']); ?>" title="<?php p($l->t('Group Search Attributes')); ?>"></textarea></p> |
|
100 | + <p><label for="ldap_group_member_assoc_attribute"><?php p($l->t('Group-Member association')); ?></label><select id="ldap_group_member_assoc_attribute" name="ldap_group_member_assoc_attribute" data-default="<?php p($_['ldap_group_member_assoc_attribute_default']); ?>" ><option value="uniqueMember"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'uniqueMember')) p(' selected'); ?>>uniqueMember</option><option value="memberUid"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'memberUid')) p(' selected'); ?>>memberUid</option><option value="member"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'member')) p(' selected'); ?>>member (AD)</option><option value="gidNumber"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'gidNumber')) p(' selected'); ?>>gidNumber</option></select></p> <p><label for="ldap_dynamic_group_member_url"><?php p($l->t('Dynamic Group Member URL')); ?></label><input type="text" id="ldap_dynamic_group_member_url" name="ldap_dynamic_group_member_url" title="<?php p($l->t('The LDAP attribute that on group objects contains an LDAP search URL that determines what objects belong to the group. (An empty setting disables dynamic group membership functionality.)')); ?>" data-default="<?php p($_['ldap_dynamic_group_member_url_default']); ?>" /></p> |
|
101 | + <p><label for="ldap_nested_groups"><?php p($l->t('Nested Groups')); ?></label><input type="checkbox" id="ldap_nested_groups" name="ldap_nested_groups" value="1" data-default="<?php p($_['ldap_nested_groups_default']); ?>" title="<?php p($l->t('When switched on, groups that contain groups are supported. (Only works if the group member attribute contains DNs.)')); ?>" /></p> |
|
102 | + <p><label for="ldap_paging_size"><?php p($l->t('Paging chunksize')); ?></label><input type="number" id="ldap_paging_size" name="ldap_paging_size" title="<?php p($l->t('Chunksize used for paged LDAP searches that may return bulky results like user or group enumeration. (Setting it 0 disables paged LDAP searches in those situations.)')); ?>" data-default="<?php p($_['ldap_paging_size_default']); ?>" /></p> |
|
103 | + <p><label for="ldap_turn_on_pwd_change"><?php p($l->t('Enable LDAP password changes per user')); ?></label><span class="inlinetable"><span class="tablerow left"><input type="checkbox" id="ldap_turn_on_pwd_change" name="ldap_turn_on_pwd_change" value="1" data-default="<?php p($_['ldap_turn_on_pwd_change_default']); ?>" title="<?php p($l->t('Allow LDAP users to change their password and allow Super Administrators and Group Administrators to change the password of their LDAP users. Only works when access control policies are configured accordingly on the LDAP server. As passwords are sent in plaintext to the LDAP server, transport encryption must be used and password hashing should be configured on the LDAP server.')); ?>" /><span class="tablecell"><?php p($l->t('(New password is sent as plain text to LDAP)')); ?></span></span> |
|
104 | 104 | </span><br/></p> |
105 | - <p><label for="ldap_default_ppolicy_dn"><?php p($l->t('Default password policy DN'));?></label><input type="text" id="ldap_default_ppolicy_dn" name="ldap_default_ppolicy_dn" title="<?php p($l->t('The DN of a default password policy that will be used for password expiry handling. Works only when LDAP password changes per user are enabled and is only supported by OpenLDAP. Leave empty to disable password expiry handling.'));?>" data-default="<?php p($_['ldap_default_ppolicy_dn_default']); ?>" /></p> |
|
105 | + <p><label for="ldap_default_ppolicy_dn"><?php p($l->t('Default password policy DN')); ?></label><input type="text" id="ldap_default_ppolicy_dn" name="ldap_default_ppolicy_dn" title="<?php p($l->t('The DN of a default password policy that will be used for password expiry handling. Works only when LDAP password changes per user are enabled and is only supported by OpenLDAP. Leave empty to disable password expiry handling.')); ?>" data-default="<?php p($_['ldap_default_ppolicy_dn_default']); ?>" /></p> |
|
106 | 106 | </div> |
107 | - <h3><?php p($l->t('Special Attributes'));?></h3> |
|
107 | + <h3><?php p($l->t('Special Attributes')); ?></h3> |
|
108 | 108 | <div> |
109 | - <p><label for="ldap_quota_attr"><?php p($l->t('Quota Field'));?></label><input type="text" id="ldap_quota_attr" name="ldap_quota_attr" data-default="<?php p($_['ldap_quota_attr_default']); ?>" title="<?php p($l->t('Leave empty for user\'s default quota. Otherwise, specify an LDAP/AD attribute.'));?>" /></p> |
|
110 | - <p><label for="ldap_quota_def"><?php p($l->t('Quota Default'));?></label><input type="text" id="ldap_quota_def" name="ldap_quota_def" data-default="<?php p($_['ldap_quota_def_default']); ?>" title="<?php p($l->t('Override default quota for LDAP users who do not have a quota set in the Quota Field.'));?>" /></p> |
|
111 | - <p><label for="ldap_email_attr"><?php p($l->t('Email Field'));?></label><input type="text" id="ldap_email_attr" name="ldap_email_attr" data-default="<?php p($_['ldap_email_attr_default']); ?>" title="<?php p($l->t('Set the user\'s email from their LDAP attribute. Leave it empty for default behaviour.'));?>" /></p> |
|
112 | - <p><label for="home_folder_naming_rule"><?php p($l->t('User Home Folder Naming Rule'));?></label><input type="text" id="home_folder_naming_rule" name="home_folder_naming_rule" title="<?php p($l->t('Leave empty for user name (default). Otherwise, specify an LDAP/AD attribute.'));?>" data-default="<?php p($_['home_folder_naming_rule_default']); ?>" /></p> |
|
109 | + <p><label for="ldap_quota_attr"><?php p($l->t('Quota Field')); ?></label><input type="text" id="ldap_quota_attr" name="ldap_quota_attr" data-default="<?php p($_['ldap_quota_attr_default']); ?>" title="<?php p($l->t('Leave empty for user\'s default quota. Otherwise, specify an LDAP/AD attribute.')); ?>" /></p> |
|
110 | + <p><label for="ldap_quota_def"><?php p($l->t('Quota Default')); ?></label><input type="text" id="ldap_quota_def" name="ldap_quota_def" data-default="<?php p($_['ldap_quota_def_default']); ?>" title="<?php p($l->t('Override default quota for LDAP users who do not have a quota set in the Quota Field.')); ?>" /></p> |
|
111 | + <p><label for="ldap_email_attr"><?php p($l->t('Email Field')); ?></label><input type="text" id="ldap_email_attr" name="ldap_email_attr" data-default="<?php p($_['ldap_email_attr_default']); ?>" title="<?php p($l->t('Set the user\'s email from their LDAP attribute. Leave it empty for default behaviour.')); ?>" /></p> |
|
112 | + <p><label for="home_folder_naming_rule"><?php p($l->t('User Home Folder Naming Rule')); ?></label><input type="text" id="home_folder_naming_rule" name="home_folder_naming_rule" title="<?php p($l->t('Leave empty for user name (default). Otherwise, specify an LDAP/AD attribute.')); ?>" data-default="<?php p($_['home_folder_naming_rule_default']); ?>" /></p> |
|
113 | 113 | </div> |
114 | 114 | </div> |
115 | 115 | <?php print_unescaped($_['settingControls']); ?> |
116 | 116 | </fieldset> |
117 | 117 | <fieldset id="ldapSettings-2"> |
118 | - <p><strong><?php p($l->t('Internal Username'));?></strong></p> |
|
119 | - <p class="ldapIndent"><?php p($l->t('By default the internal username will be created from the UUID attribute. It makes sure that the username is unique and characters do not need to be converted. The internal username has the restriction that only these characters are allowed: [ a-zA-Z0-9_.@- ]. Other characters are replaced with their ASCII correspondence or simply omitted. On collisions a number will be added/increased. The internal username is used to identify a user internally. It is also the default name for the user home folder. It is also a part of remote URLs, for instance for all *DAV services. With this setting, the default behavior can be overridden. Leave it empty for default behavior. Changes will have effect only on newly mapped (added) LDAP users.'));?></p> |
|
120 | - <p class="ldapIndent"><label for="ldap_expert_username_attr"><?php p($l->t('Internal Username Attribute:'));?></label><input type="text" id="ldap_expert_username_attr" name="ldap_expert_username_attr" data-default="<?php p($_['ldap_expert_username_attr_default']); ?>" /></p> |
|
121 | - <p><strong><?php p($l->t('Override UUID detection'));?></strong></p> |
|
122 | - <p class="ldapIndent"><?php p($l->t('By default, the UUID attribute is automatically detected. The UUID attribute is used to doubtlessly identify LDAP users and groups. Also, the internal username will be created based on the UUID, if not specified otherwise above. You can override the setting and pass an attribute of your choice. You must make sure that the attribute of your choice can be fetched for both users and groups and it is unique. Leave it empty for default behavior. Changes will have effect only on newly mapped (added) LDAP users and groups.'));?></p> |
|
123 | - <p class="ldapIndent"><label for="ldap_expert_uuid_user_attr"><?php p($l->t('UUID Attribute for Users:'));?></label><input type="text" id="ldap_expert_uuid_user_attr" name="ldap_expert_uuid_user_attr" data-default="<?php p($_['ldap_expert_uuid_user_attr_default']); ?>" /></p> |
|
124 | - <p class="ldapIndent"><label for="ldap_expert_uuid_group_attr"><?php p($l->t('UUID Attribute for Groups:'));?></label><input type="text" id="ldap_expert_uuid_group_attr" name="ldap_expert_uuid_group_attr" data-default="<?php p($_['ldap_expert_uuid_group_attr_default']); ?>" /></p> |
|
125 | - <p><strong><?php p($l->t('Username-LDAP User Mapping'));?></strong></p> |
|
126 | - <p class="ldapIndent"><?php p($l->t('Usernames are used to store and assign (meta) data. In order to precisely identify and recognize users, each LDAP user will have an internal username. This requires a mapping from username to LDAP user. The created username is mapped to the UUID of the LDAP user. Additionally the DN is cached as well to reduce LDAP interaction, but it is not used for identification. If the DN changes, the changes will be found. The internal username is used all over. Clearing the mappings will have leftovers everywhere. Clearing the mappings is not configuration sensitive, it affects all LDAP configurations! Never clear the mappings in a production environment, only in a testing or experimental stage.'));?></p> |
|
127 | - <p class="ldapIndent"><button type="button" id="ldap_action_clear_user_mappings" name="ldap_action_clear_user_mappings"><?php p($l->t('Clear Username-LDAP User Mapping'));?></button><br/><button type="button" id="ldap_action_clear_group_mappings" name="ldap_action_clear_group_mappings"><?php p($l->t('Clear Groupname-LDAP Group Mapping'));?></button></p> |
|
118 | + <p><strong><?php p($l->t('Internal Username')); ?></strong></p> |
|
119 | + <p class="ldapIndent"><?php p($l->t('By default the internal username will be created from the UUID attribute. It makes sure that the username is unique and characters do not need to be converted. The internal username has the restriction that only these characters are allowed: [ a-zA-Z0-9_.@- ]. Other characters are replaced with their ASCII correspondence or simply omitted. On collisions a number will be added/increased. The internal username is used to identify a user internally. It is also the default name for the user home folder. It is also a part of remote URLs, for instance for all *DAV services. With this setting, the default behavior can be overridden. Leave it empty for default behavior. Changes will have effect only on newly mapped (added) LDAP users.')); ?></p> |
|
120 | + <p class="ldapIndent"><label for="ldap_expert_username_attr"><?php p($l->t('Internal Username Attribute:')); ?></label><input type="text" id="ldap_expert_username_attr" name="ldap_expert_username_attr" data-default="<?php p($_['ldap_expert_username_attr_default']); ?>" /></p> |
|
121 | + <p><strong><?php p($l->t('Override UUID detection')); ?></strong></p> |
|
122 | + <p class="ldapIndent"><?php p($l->t('By default, the UUID attribute is automatically detected. The UUID attribute is used to doubtlessly identify LDAP users and groups. Also, the internal username will be created based on the UUID, if not specified otherwise above. You can override the setting and pass an attribute of your choice. You must make sure that the attribute of your choice can be fetched for both users and groups and it is unique. Leave it empty for default behavior. Changes will have effect only on newly mapped (added) LDAP users and groups.')); ?></p> |
|
123 | + <p class="ldapIndent"><label for="ldap_expert_uuid_user_attr"><?php p($l->t('UUID Attribute for Users:')); ?></label><input type="text" id="ldap_expert_uuid_user_attr" name="ldap_expert_uuid_user_attr" data-default="<?php p($_['ldap_expert_uuid_user_attr_default']); ?>" /></p> |
|
124 | + <p class="ldapIndent"><label for="ldap_expert_uuid_group_attr"><?php p($l->t('UUID Attribute for Groups:')); ?></label><input type="text" id="ldap_expert_uuid_group_attr" name="ldap_expert_uuid_group_attr" data-default="<?php p($_['ldap_expert_uuid_group_attr_default']); ?>" /></p> |
|
125 | + <p><strong><?php p($l->t('Username-LDAP User Mapping')); ?></strong></p> |
|
126 | + <p class="ldapIndent"><?php p($l->t('Usernames are used to store and assign (meta) data. In order to precisely identify and recognize users, each LDAP user will have an internal username. This requires a mapping from username to LDAP user. The created username is mapped to the UUID of the LDAP user. Additionally the DN is cached as well to reduce LDAP interaction, but it is not used for identification. If the DN changes, the changes will be found. The internal username is used all over. Clearing the mappings will have leftovers everywhere. Clearing the mappings is not configuration sensitive, it affects all LDAP configurations! Never clear the mappings in a production environment, only in a testing or experimental stage.')); ?></p> |
|
127 | + <p class="ldapIndent"><button type="button" id="ldap_action_clear_user_mappings" name="ldap_action_clear_user_mappings"><?php p($l->t('Clear Username-LDAP User Mapping')); ?></button><br/><button type="button" id="ldap_action_clear_group_mappings" name="ldap_action_clear_group_mappings"><?php p($l->t('Clear Groupname-LDAP Group Mapping')); ?></button></p> |
|
128 | 128 | <?php print_unescaped($_['settingControls']); ?> |
129 | 129 | </fieldset> |
130 | 130 | </div> |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | parent::__construct($access); |
58 | 58 | $filter = $this->access->connection->ldapGroupFilter; |
59 | 59 | $gassoc = $this->access->connection->ldapGroupMemberAssocAttr; |
60 | - if(!empty($filter) && !empty($gassoc)) { |
|
60 | + if (!empty($filter) && !empty($gassoc)) { |
|
61 | 61 | $this->enabled = true; |
62 | 62 | } |
63 | 63 | |
@@ -74,25 +74,25 @@ discard block |
||
74 | 74 | * Checks whether the user is member of a group or not. |
75 | 75 | */ |
76 | 76 | public function inGroup($uid, $gid) { |
77 | - if(!$this->enabled) { |
|
77 | + if (!$this->enabled) { |
|
78 | 78 | return false; |
79 | 79 | } |
80 | 80 | $cacheKey = 'inGroup'.$uid.':'.$gid; |
81 | 81 | $inGroup = $this->access->connection->getFromCache($cacheKey); |
82 | - if(!is_null($inGroup)) { |
|
83 | - return (bool)$inGroup; |
|
82 | + if (!is_null($inGroup)) { |
|
83 | + return (bool) $inGroup; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | $userDN = $this->access->username2dn($uid); |
87 | 87 | |
88 | - if(isset($this->cachedGroupMembers[$gid])) { |
|
88 | + if (isset($this->cachedGroupMembers[$gid])) { |
|
89 | 89 | $isInGroup = in_array($userDN, $this->cachedGroupMembers[$gid]); |
90 | 90 | return $isInGroup; |
91 | 91 | } |
92 | 92 | |
93 | 93 | $cacheKeyMembers = 'inGroup-members:'.$gid; |
94 | 94 | $members = $this->access->connection->getFromCache($cacheKeyMembers); |
95 | - if(!is_null($members)) { |
|
95 | + if (!is_null($members)) { |
|
96 | 96 | $this->cachedGroupMembers[$gid] = $members; |
97 | 97 | $isInGroup = in_array($userDN, $members); |
98 | 98 | $this->access->connection->writeToCache($cacheKey, $isInGroup); |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | |
102 | 102 | $groupDN = $this->access->groupname2dn($gid); |
103 | 103 | // just in case |
104 | - if(!$groupDN || !$userDN) { |
|
104 | + if (!$groupDN || !$userDN) { |
|
105 | 105 | $this->access->connection->writeToCache($cacheKey, false); |
106 | 106 | return false; |
107 | 107 | } |
108 | 108 | |
109 | 109 | //check primary group first |
110 | - if($gid === $this->getUserPrimaryGroup($userDN)) { |
|
110 | + if ($gid === $this->getUserPrimaryGroup($userDN)) { |
|
111 | 111 | $this->access->connection->writeToCache($cacheKey, true); |
112 | 112 | return true; |
113 | 113 | } |
@@ -115,21 +115,21 @@ discard block |
||
115 | 115 | //usually, LDAP attributes are said to be case insensitive. But there are exceptions of course. |
116 | 116 | $members = $this->_groupMembers($groupDN); |
117 | 117 | $members = array_keys($members); // uids are returned as keys |
118 | - if(!is_array($members) || count($members) === 0) { |
|
118 | + if (!is_array($members) || count($members) === 0) { |
|
119 | 119 | $this->access->connection->writeToCache($cacheKey, false); |
120 | 120 | return false; |
121 | 121 | } |
122 | 122 | |
123 | 123 | //extra work if we don't get back user DNs |
124 | - if(strtolower($this->access->connection->ldapGroupMemberAssocAttr) === 'memberuid') { |
|
124 | + if (strtolower($this->access->connection->ldapGroupMemberAssocAttr) === 'memberuid') { |
|
125 | 125 | $dns = array(); |
126 | 126 | $filterParts = array(); |
127 | 127 | $bytes = 0; |
128 | - foreach($members as $mid) { |
|
128 | + foreach ($members as $mid) { |
|
129 | 129 | $filter = str_replace('%uid', $mid, $this->access->connection->ldapLoginFilter); |
130 | 130 | $filterParts[] = $filter; |
131 | 131 | $bytes += strlen($filter); |
132 | - if($bytes >= 9000000) { |
|
132 | + if ($bytes >= 9000000) { |
|
133 | 133 | // AD has a default input buffer of 10 MB, we do not want |
134 | 134 | // to take even the chance to exceed it |
135 | 135 | $filter = $this->access->combineFilterWithOr($filterParts); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $dns = array_merge($dns, $users); |
140 | 140 | } |
141 | 141 | } |
142 | - if(count($filterParts) > 0) { |
|
142 | + if (count($filterParts) > 0) { |
|
143 | 143 | $filter = $this->access->combineFilterWithOr($filterParts); |
144 | 144 | $users = $this->access->fetchListOfUsers($filter, 'dn', count($filterParts)); |
145 | 145 | $dns = array_merge($dns, $users); |
@@ -182,14 +182,14 @@ discard block |
||
182 | 182 | $pos = strpos($memberURLs[0], '('); |
183 | 183 | if ($pos !== false) { |
184 | 184 | $memberUrlFilter = substr($memberURLs[0], $pos); |
185 | - $foundMembers = $this->access->searchUsers($memberUrlFilter,'dn'); |
|
185 | + $foundMembers = $this->access->searchUsers($memberUrlFilter, 'dn'); |
|
186 | 186 | $dynamicMembers = array(); |
187 | - foreach($foundMembers as $value) { |
|
187 | + foreach ($foundMembers as $value) { |
|
188 | 188 | $dynamicMembers[$value['dn'][0]] = 1; |
189 | 189 | } |
190 | 190 | } else { |
191 | 191 | \OCP\Util::writeLog('user_ldap', 'No search filter found on member url '. |
192 | - 'of group ' . $dnGroup, \OCP\Util::DEBUG); |
|
192 | + 'of group '.$dnGroup, \OCP\Util::DEBUG); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | return $dynamicMembers; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | // used extensively in cron job, caching makes sense for nested groups |
213 | 213 | $cacheKey = '_groupMembers'.$dnGroup; |
214 | 214 | $groupMembers = $this->access->connection->getFromCache($cacheKey); |
215 | - if(!is_null($groupMembers)) { |
|
215 | + if (!is_null($groupMembers)) { |
|
216 | 216 | return $groupMembers; |
217 | 217 | } |
218 | 218 | $seen[$dnGroup] = 1; |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | return array(); |
257 | 257 | } |
258 | 258 | $groups = $this->access->groupsMatchFilter($groups); |
259 | - $allGroups = $groups; |
|
259 | + $allGroups = $groups; |
|
260 | 260 | $nestedGroups = $this->access->connection->ldapNestedGroups; |
261 | 261 | if (intval($nestedGroups) === 1) { |
262 | 262 | foreach ($groups as $group) { |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | * @return string|bool |
275 | 275 | */ |
276 | 276 | public function gidNumber2Name($gid, $dn) { |
277 | - $cacheKey = 'gidNumberToName' . $gid; |
|
277 | + $cacheKey = 'gidNumberToName'.$gid; |
|
278 | 278 | $groupName = $this->access->connection->getFromCache($cacheKey); |
279 | - if(!is_null($groupName) && isset($groupName)) { |
|
279 | + if (!is_null($groupName) && isset($groupName)) { |
|
280 | 280 | return $groupName; |
281 | 281 | } |
282 | 282 | |
@@ -284,10 +284,10 @@ discard block |
||
284 | 284 | $filter = $this->access->combineFilterWithAnd([ |
285 | 285 | $this->access->connection->ldapGroupFilter, |
286 | 286 | 'objectClass=posixGroup', |
287 | - $this->access->connection->ldapGidNumber . '=' . $gid |
|
287 | + $this->access->connection->ldapGidNumber.'='.$gid |
|
288 | 288 | ]); |
289 | 289 | $result = $this->access->searchGroups($filter, array('dn'), 1); |
290 | - if(empty($result)) { |
|
290 | + if (empty($result)) { |
|
291 | 291 | return false; |
292 | 292 | } |
293 | 293 | $dn = $result[0]['dn'][0]; |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | */ |
311 | 311 | private function getEntryGidNumber($dn, $attribute) { |
312 | 312 | $value = $this->access->readAttribute($dn, $attribute); |
313 | - if(is_array($value) && !empty($value)) { |
|
313 | + if (is_array($value) && !empty($value)) { |
|
314 | 314 | return $value[0]; |
315 | 315 | } |
316 | 316 | return false; |
@@ -332,9 +332,9 @@ discard block |
||
332 | 332 | */ |
333 | 333 | public function getUserGidNumber($dn) { |
334 | 334 | $gidNumber = false; |
335 | - if($this->access->connection->hasGidNumber) { |
|
335 | + if ($this->access->connection->hasGidNumber) { |
|
336 | 336 | $gidNumber = $this->getEntryGidNumber($dn, 'gidNumber'); |
337 | - if($gidNumber === false) { |
|
337 | + if ($gidNumber === false) { |
|
338 | 338 | $this->access->connection->hasGidNumber = false; |
339 | 339 | } |
340 | 340 | } |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | */ |
352 | 352 | private function prepareFilterForUsersHasGidNumber($groupDN, $search = '') { |
353 | 353 | $groupID = $this->getGroupGidNumber($groupDN); |
354 | - if($groupID === false) { |
|
354 | + if ($groupID === false) { |
|
355 | 355 | throw new \Exception('Not a valid group'); |
356 | 356 | } |
357 | 357 | |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | if ($search !== '') { |
361 | 361 | $filterParts[] = $this->access->getFilterPartForUserSearch($search); |
362 | 362 | } |
363 | - $filterParts[] = $this->access->connection->ldapGidNumber .'=' . $groupID; |
|
363 | + $filterParts[] = $this->access->connection->ldapGidNumber.'='.$groupID; |
|
364 | 364 | |
365 | 365 | $filter = $this->access->combineFilterWithAnd($filterParts); |
366 | 366 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | try { |
405 | 405 | $filter = $this->prepareFilterForUsersHasGidNumber($groupDN, $search); |
406 | 406 | $users = $this->access->countUsers($filter, ['dn'], $limit, $offset); |
407 | - return (int)$users; |
|
407 | + return (int) $users; |
|
408 | 408 | } catch (\Exception $e) { |
409 | 409 | return 0; |
410 | 410 | } |
@@ -417,9 +417,9 @@ discard block |
||
417 | 417 | */ |
418 | 418 | public function getUserGroupByGid($dn) { |
419 | 419 | $groupID = $this->getUserGidNumber($dn); |
420 | - if($groupID !== false) { |
|
420 | + if ($groupID !== false) { |
|
421 | 421 | $groupName = $this->gidNumber2Name($groupID, $dn); |
422 | - if($groupName !== false) { |
|
422 | + if ($groupName !== false) { |
|
423 | 423 | return $groupName; |
424 | 424 | } |
425 | 425 | } |
@@ -436,22 +436,22 @@ discard block |
||
436 | 436 | public function primaryGroupID2Name($gid, $dn) { |
437 | 437 | $cacheKey = 'primaryGroupIDtoName'; |
438 | 438 | $groupNames = $this->access->connection->getFromCache($cacheKey); |
439 | - if(!is_null($groupNames) && isset($groupNames[$gid])) { |
|
439 | + if (!is_null($groupNames) && isset($groupNames[$gid])) { |
|
440 | 440 | return $groupNames[$gid]; |
441 | 441 | } |
442 | 442 | |
443 | 443 | $domainObjectSid = $this->access->getSID($dn); |
444 | - if($domainObjectSid === false) { |
|
444 | + if ($domainObjectSid === false) { |
|
445 | 445 | return false; |
446 | 446 | } |
447 | 447 | |
448 | 448 | //we need to get the DN from LDAP |
449 | 449 | $filter = $this->access->combineFilterWithAnd(array( |
450 | 450 | $this->access->connection->ldapGroupFilter, |
451 | - 'objectsid=' . $domainObjectSid . '-' . $gid |
|
451 | + 'objectsid='.$domainObjectSid.'-'.$gid |
|
452 | 452 | )); |
453 | 453 | $result = $this->access->searchGroups($filter, array('dn'), 1); |
454 | - if(empty($result)) { |
|
454 | + if (empty($result)) { |
|
455 | 455 | return false; |
456 | 456 | } |
457 | 457 | $dn = $result[0]['dn'][0]; |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | */ |
475 | 475 | private function getEntryGroupID($dn, $attribute) { |
476 | 476 | $value = $this->access->readAttribute($dn, $attribute); |
477 | - if(is_array($value) && !empty($value)) { |
|
477 | + if (is_array($value) && !empty($value)) { |
|
478 | 478 | return $value[0]; |
479 | 479 | } |
480 | 480 | return false; |
@@ -496,9 +496,9 @@ discard block |
||
496 | 496 | */ |
497 | 497 | public function getUserPrimaryGroupIDs($dn) { |
498 | 498 | $primaryGroupID = false; |
499 | - if($this->access->connection->hasPrimaryGroups) { |
|
499 | + if ($this->access->connection->hasPrimaryGroups) { |
|
500 | 500 | $primaryGroupID = $this->getEntryGroupID($dn, 'primaryGroupID'); |
501 | - if($primaryGroupID === false) { |
|
501 | + if ($primaryGroupID === false) { |
|
502 | 502 | $this->access->connection->hasPrimaryGroups = false; |
503 | 503 | } |
504 | 504 | } |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | */ |
516 | 516 | private function prepareFilterForUsersInPrimaryGroup($groupDN, $search = '') { |
517 | 517 | $groupID = $this->getGroupPrimaryGroupID($groupDN); |
518 | - if($groupID === false) { |
|
518 | + if ($groupID === false) { |
|
519 | 519 | throw new \Exception('Not a valid group'); |
520 | 520 | } |
521 | 521 | |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | if ($search !== '') { |
525 | 525 | $filterParts[] = $this->access->getFilterPartForUserSearch($search); |
526 | 526 | } |
527 | - $filterParts[] = 'primaryGroupID=' . $groupID; |
|
527 | + $filterParts[] = 'primaryGroupID='.$groupID; |
|
528 | 528 | |
529 | 529 | $filter = $this->access->combineFilterWithAnd($filterParts); |
530 | 530 | |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | try { |
569 | 569 | $filter = $this->prepareFilterForUsersInPrimaryGroup($groupDN, $search); |
570 | 570 | $users = $this->access->countUsers($filter, array('dn'), $limit, $offset); |
571 | - return (int)$users; |
|
571 | + return (int) $users; |
|
572 | 572 | } catch (\Exception $e) { |
573 | 573 | return 0; |
574 | 574 | } |
@@ -581,9 +581,9 @@ discard block |
||
581 | 581 | */ |
582 | 582 | public function getUserPrimaryGroup($dn) { |
583 | 583 | $groupID = $this->getUserPrimaryGroupIDs($dn); |
584 | - if($groupID !== false) { |
|
584 | + if ($groupID !== false) { |
|
585 | 585 | $groupName = $this->primaryGroupID2Name($groupID, $dn); |
586 | - if($groupName !== false) { |
|
586 | + if ($groupName !== false) { |
|
587 | 587 | return $groupName; |
588 | 588 | } |
589 | 589 | } |
@@ -602,16 +602,16 @@ discard block |
||
602 | 602 | * This function includes groups based on dynamic group membership. |
603 | 603 | */ |
604 | 604 | public function getUserGroups($uid) { |
605 | - if(!$this->enabled) { |
|
605 | + if (!$this->enabled) { |
|
606 | 606 | return array(); |
607 | 607 | } |
608 | 608 | $cacheKey = 'getUserGroups'.$uid; |
609 | 609 | $userGroups = $this->access->connection->getFromCache($cacheKey); |
610 | - if(!is_null($userGroups)) { |
|
610 | + if (!is_null($userGroups)) { |
|
611 | 611 | return $userGroups; |
612 | 612 | } |
613 | 613 | $userDN = $this->access->username2dn($uid); |
614 | - if(!$userDN) { |
|
614 | + if (!$userDN) { |
|
615 | 615 | $this->access->connection->writeToCache($cacheKey, array()); |
616 | 616 | return array(); |
617 | 617 | } |
@@ -625,14 +625,14 @@ discard block |
||
625 | 625 | if (!empty($dynamicGroupMemberURL)) { |
626 | 626 | // look through dynamic groups to add them to the result array if needed |
627 | 627 | $groupsToMatch = $this->access->fetchListOfGroups( |
628 | - $this->access->connection->ldapGroupFilter,array('dn',$dynamicGroupMemberURL)); |
|
629 | - foreach($groupsToMatch as $dynamicGroup) { |
|
628 | + $this->access->connection->ldapGroupFilter, array('dn', $dynamicGroupMemberURL)); |
|
629 | + foreach ($groupsToMatch as $dynamicGroup) { |
|
630 | 630 | if (!array_key_exists($dynamicGroupMemberURL, $dynamicGroup)) { |
631 | 631 | continue; |
632 | 632 | } |
633 | 633 | $pos = strpos($dynamicGroup[$dynamicGroupMemberURL][0], '('); |
634 | 634 | if ($pos !== false) { |
635 | - $memberUrlFilter = substr($dynamicGroup[$dynamicGroupMemberURL][0],$pos); |
|
635 | + $memberUrlFilter = substr($dynamicGroup[$dynamicGroupMemberURL][0], $pos); |
|
636 | 636 | // apply filter via ldap search to see if this user is in this |
637 | 637 | // dynamic group |
638 | 638 | $userMatch = $this->access->readAttribute( |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | if ($userMatch !== false) { |
644 | 644 | // match found so this user is in this group |
645 | 645 | $groupName = $this->access->dn2groupname($dynamicGroup['dn'][0]); |
646 | - if(is_string($groupName)) { |
|
646 | + if (is_string($groupName)) { |
|
647 | 647 | // be sure to never return false if the dn could not be |
648 | 648 | // resolved to a name, for whatever reason. |
649 | 649 | $groups[] = $groupName; |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | } |
652 | 652 | } else { |
653 | 653 | \OCP\Util::writeLog('user_ldap', 'No search filter found on member url '. |
654 | - 'of group ' . print_r($dynamicGroup, true), \OCP\Util::DEBUG); |
|
654 | + 'of group '.print_r($dynamicGroup, true), \OCP\Util::DEBUG); |
|
655 | 655 | } |
656 | 656 | } |
657 | 657 | } |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | // if possible, read out membership via memberOf. It's far faster than |
660 | 660 | // performing a search, which still is a fallback later. |
661 | 661 | // memberof doesn't support memberuid, so skip it here. |
662 | - if(intval($this->access->connection->hasMemberOfFilterSupport) === 1 |
|
662 | + if (intval($this->access->connection->hasMemberOfFilterSupport) === 1 |
|
663 | 663 | && intval($this->access->connection->useMemberOfToDetectMembership) === 1 |
664 | 664 | && strtolower($this->access->connection->ldapGroupMemberAssocAttr) !== 'memberuid' |
665 | 665 | ) { |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | if (is_array($groupDNs)) { |
668 | 668 | foreach ($groupDNs as $dn) { |
669 | 669 | $groupName = $this->access->dn2groupname($dn); |
670 | - if(is_string($groupName)) { |
|
670 | + if (is_string($groupName)) { |
|
671 | 671 | // be sure to never return false if the dn could not be |
672 | 672 | // resolved to a name, for whatever reason. |
673 | 673 | $groups[] = $groupName; |
@@ -675,10 +675,10 @@ discard block |
||
675 | 675 | } |
676 | 676 | } |
677 | 677 | |
678 | - if($primaryGroup !== false) { |
|
678 | + if ($primaryGroup !== false) { |
|
679 | 679 | $groups[] = $primaryGroup; |
680 | 680 | } |
681 | - if($gidGroupName !== false) { |
|
681 | + if ($gidGroupName !== false) { |
|
682 | 682 | $groups[] = $gidGroupName; |
683 | 683 | } |
684 | 684 | $this->access->connection->writeToCache($cacheKey, $groups); |
@@ -686,14 +686,14 @@ discard block |
||
686 | 686 | } |
687 | 687 | |
688 | 688 | //uniqueMember takes DN, memberuid the uid, so we need to distinguish |
689 | - if((strtolower($this->access->connection->ldapGroupMemberAssocAttr) === 'uniquemember') |
|
689 | + if ((strtolower($this->access->connection->ldapGroupMemberAssocAttr) === 'uniquemember') |
|
690 | 690 | || (strtolower($this->access->connection->ldapGroupMemberAssocAttr) === 'member') |
691 | 691 | ) { |
692 | 692 | $uid = $userDN; |
693 | - } else if(strtolower($this->access->connection->ldapGroupMemberAssocAttr) === 'memberuid') { |
|
693 | + } else if (strtolower($this->access->connection->ldapGroupMemberAssocAttr) === 'memberuid') { |
|
694 | 694 | $result = $this->access->readAttribute($userDN, 'uid'); |
695 | 695 | if ($result === false) { |
696 | - \OCP\Util::writeLog('user_ldap', 'No uid attribute found for DN ' . $userDN . ' on '. |
|
696 | + \OCP\Util::writeLog('user_ldap', 'No uid attribute found for DN '.$userDN.' on '. |
|
697 | 697 | $this->access->connection->ldapHost, \OCP\Util::DEBUG); |
698 | 698 | } |
699 | 699 | $uid = $result[0]; |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | $uid = $userDN; |
703 | 703 | } |
704 | 704 | |
705 | - if(isset($this->cachedGroupsByMember[$uid])) { |
|
705 | + if (isset($this->cachedGroupsByMember[$uid])) { |
|
706 | 706 | $groups = array_merge($groups, $this->cachedGroupsByMember[$uid]); |
707 | 707 | } else { |
708 | 708 | $groupsByMember = array_values($this->getGroupsByMember($uid)); |
@@ -711,10 +711,10 @@ discard block |
||
711 | 711 | $groups = array_merge($groups, $groupsByMember); |
712 | 712 | } |
713 | 713 | |
714 | - if($primaryGroup !== false) { |
|
714 | + if ($primaryGroup !== false) { |
|
715 | 715 | $groups[] = $primaryGroup; |
716 | 716 | } |
717 | - if($gidGroupName !== false) { |
|
717 | + if ($gidGroupName !== false) { |
|
718 | 718 | $groups[] = $gidGroupName; |
719 | 719 | } |
720 | 720 | |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | $nestedGroups = $this->access->connection->ldapNestedGroups; |
753 | 753 | if (!empty($nestedGroups)) { |
754 | 754 | $supergroups = $this->getGroupsByMember($groupDN, $seen); |
755 | - if (is_array($supergroups) && (count($supergroups)>0)) { |
|
755 | + if (is_array($supergroups) && (count($supergroups) > 0)) { |
|
756 | 756 | $allGroups = array_merge($allGroups, $supergroups); |
757 | 757 | } |
758 | 758 | } |
@@ -771,33 +771,33 @@ discard block |
||
771 | 771 | * @return array with user ids |
772 | 772 | */ |
773 | 773 | public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) { |
774 | - if(!$this->enabled) { |
|
774 | + if (!$this->enabled) { |
|
775 | 775 | return array(); |
776 | 776 | } |
777 | - if(!$this->groupExists($gid)) { |
|
777 | + if (!$this->groupExists($gid)) { |
|
778 | 778 | return array(); |
779 | 779 | } |
780 | 780 | $search = $this->access->escapeFilterPart($search, true); |
781 | 781 | $cacheKey = 'usersInGroup-'.$gid.'-'.$search.'-'.$limit.'-'.$offset; |
782 | 782 | // check for cache of the exact query |
783 | 783 | $groupUsers = $this->access->connection->getFromCache($cacheKey); |
784 | - if(!is_null($groupUsers)) { |
|
784 | + if (!is_null($groupUsers)) { |
|
785 | 785 | return $groupUsers; |
786 | 786 | } |
787 | 787 | |
788 | 788 | // check for cache of the query without limit and offset |
789 | 789 | $groupUsers = $this->access->connection->getFromCache('usersInGroup-'.$gid.'-'.$search); |
790 | - if(!is_null($groupUsers)) { |
|
790 | + if (!is_null($groupUsers)) { |
|
791 | 791 | $groupUsers = array_slice($groupUsers, $offset, $limit); |
792 | 792 | $this->access->connection->writeToCache($cacheKey, $groupUsers); |
793 | 793 | return $groupUsers; |
794 | 794 | } |
795 | 795 | |
796 | - if($limit === -1) { |
|
796 | + if ($limit === -1) { |
|
797 | 797 | $limit = null; |
798 | 798 | } |
799 | 799 | $groupDN = $this->access->groupname2dn($gid); |
800 | - if(!$groupDN) { |
|
800 | + if (!$groupDN) { |
|
801 | 801 | // group couldn't be found, return empty resultset |
802 | 802 | $this->access->connection->writeToCache($cacheKey, array()); |
803 | 803 | return array(); |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | |
806 | 806 | $primaryUsers = $this->getUsersInPrimaryGroup($groupDN, $search, $limit, $offset); |
807 | 807 | $members = array_keys($this->_groupMembers($groupDN)); |
808 | - if(!$members && empty($primaryUsers)) { |
|
808 | + if (!$members && empty($primaryUsers)) { |
|
809 | 809 | //in case users could not be retrieved, return empty result set |
810 | 810 | $this->access->connection->writeToCache($cacheKey, array()); |
811 | 811 | return array(); |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | |
814 | 814 | $posixGroupUsers = $this->getUsersInGidNumber($groupDN, $search, $limit, $offset); |
815 | 815 | $members = array_keys($this->_groupMembers($groupDN)); |
816 | - if(!$members && empty($posixGroupUsers)) { |
|
816 | + if (!$members && empty($posixGroupUsers)) { |
|
817 | 817 | //in case users could not be retrieved, return empty result set |
818 | 818 | $this->access->connection->writeToCache($cacheKey, []); |
819 | 819 | return []; |
@@ -822,29 +822,29 @@ discard block |
||
822 | 822 | $groupUsers = array(); |
823 | 823 | $isMemberUid = (strtolower($this->access->connection->ldapGroupMemberAssocAttr) === 'memberuid'); |
824 | 824 | $attrs = $this->access->userManager->getAttributes(true); |
825 | - foreach($members as $member) { |
|
826 | - if($isMemberUid) { |
|
825 | + foreach ($members as $member) { |
|
826 | + if ($isMemberUid) { |
|
827 | 827 | //we got uids, need to get their DNs to 'translate' them to user names |
828 | 828 | $filter = $this->access->combineFilterWithAnd(array( |
829 | 829 | str_replace('%uid', $member, $this->access->connection->ldapLoginFilter), |
830 | 830 | $this->access->getFilterPartForUserSearch($search) |
831 | 831 | )); |
832 | 832 | $ldap_users = $this->access->fetchListOfUsers($filter, $attrs, 1); |
833 | - if(count($ldap_users) < 1) { |
|
833 | + if (count($ldap_users) < 1) { |
|
834 | 834 | continue; |
835 | 835 | } |
836 | 836 | $groupUsers[] = $this->access->dn2username($ldap_users[0]['dn'][0]); |
837 | 837 | } else { |
838 | 838 | //we got DNs, check if we need to filter by search or we can give back all of them |
839 | 839 | if ($search !== '') { |
840 | - if(!$this->access->readAttribute($member, |
|
840 | + if (!$this->access->readAttribute($member, |
|
841 | 841 | $this->access->connection->ldapUserDisplayName, |
842 | 842 | $this->access->getFilterPartForUserSearch($search))) { |
843 | 843 | continue; |
844 | 844 | } |
845 | 845 | } |
846 | 846 | // dn2username will also check if the users belong to the allowed base |
847 | - if($ocname = $this->access->dn2username($member)) { |
|
847 | + if ($ocname = $this->access->dn2username($member)) { |
|
848 | 848 | $groupUsers[] = $ocname; |
849 | 849 | } |
850 | 850 | } |
@@ -873,16 +873,16 @@ discard block |
||
873 | 873 | */ |
874 | 874 | public function countUsersInGroup($gid, $search = '') { |
875 | 875 | $cacheKey = 'countUsersInGroup-'.$gid.'-'.$search; |
876 | - if(!$this->enabled || !$this->groupExists($gid)) { |
|
876 | + if (!$this->enabled || !$this->groupExists($gid)) { |
|
877 | 877 | return false; |
878 | 878 | } |
879 | 879 | $groupUsers = $this->access->connection->getFromCache($cacheKey); |
880 | - if(!is_null($groupUsers)) { |
|
880 | + if (!is_null($groupUsers)) { |
|
881 | 881 | return $groupUsers; |
882 | 882 | } |
883 | 883 | |
884 | 884 | $groupDN = $this->access->groupname2dn($gid); |
885 | - if(!$groupDN) { |
|
885 | + if (!$groupDN) { |
|
886 | 886 | // group couldn't be found, return empty result set |
887 | 887 | $this->access->connection->writeToCache($cacheKey, false); |
888 | 888 | return false; |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | |
891 | 891 | $members = array_keys($this->_groupMembers($groupDN)); |
892 | 892 | $primaryUserCount = $this->countUsersInPrimaryGroup($groupDN, ''); |
893 | - if(!$members && $primaryUserCount === 0) { |
|
893 | + if (!$members && $primaryUserCount === 0) { |
|
894 | 894 | //in case users could not be retrieved, return empty result set |
895 | 895 | $this->access->connection->writeToCache($cacheKey, false); |
896 | 896 | return false; |
@@ -915,27 +915,27 @@ discard block |
||
915 | 915 | //For now this is not important, because the only use of this method |
916 | 916 | //does not supply a search string |
917 | 917 | $groupUsers = array(); |
918 | - foreach($members as $member) { |
|
919 | - if($isMemberUid) { |
|
918 | + foreach ($members as $member) { |
|
919 | + if ($isMemberUid) { |
|
920 | 920 | //we got uids, need to get their DNs to 'translate' them to user names |
921 | 921 | $filter = $this->access->combineFilterWithAnd(array( |
922 | 922 | str_replace('%uid', $member, $this->access->connection->ldapLoginFilter), |
923 | 923 | $this->access->getFilterPartForUserSearch($search) |
924 | 924 | )); |
925 | 925 | $ldap_users = $this->access->fetchListOfUsers($filter, 'dn', 1); |
926 | - if(count($ldap_users) < 1) { |
|
926 | + if (count($ldap_users) < 1) { |
|
927 | 927 | continue; |
928 | 928 | } |
929 | 929 | $groupUsers[] = $this->access->dn2username($ldap_users[0]); |
930 | 930 | } else { |
931 | 931 | //we need to apply the search filter now |
932 | - if(!$this->access->readAttribute($member, |
|
932 | + if (!$this->access->readAttribute($member, |
|
933 | 933 | $this->access->connection->ldapUserDisplayName, |
934 | 934 | $this->access->getFilterPartForUserSearch($search))) { |
935 | 935 | continue; |
936 | 936 | } |
937 | 937 | // dn2username will also check if the users belong to the allowed base |
938 | - if($ocname = $this->access->dn2username($member)) { |
|
938 | + if ($ocname = $this->access->dn2username($member)) { |
|
939 | 939 | $groupUsers[] = $ocname; |
940 | 940 | } |
941 | 941 | } |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | * Returns a list with all groups (used by getGroups) |
959 | 959 | */ |
960 | 960 | protected function getGroupsChunk($search = '', $limit = -1, $offset = 0) { |
961 | - if(!$this->enabled) { |
|
961 | + if (!$this->enabled) { |
|
962 | 962 | return array(); |
963 | 963 | } |
964 | 964 | $cacheKey = 'getGroups-'.$search.'-'.$limit.'-'.$offset; |
@@ -966,13 +966,13 @@ discard block |
||
966 | 966 | //Check cache before driving unnecessary searches |
967 | 967 | \OCP\Util::writeLog('user_ldap', 'getGroups '.$cacheKey, \OCP\Util::DEBUG); |
968 | 968 | $ldap_groups = $this->access->connection->getFromCache($cacheKey); |
969 | - if(!is_null($ldap_groups)) { |
|
969 | + if (!is_null($ldap_groups)) { |
|
970 | 970 | return $ldap_groups; |
971 | 971 | } |
972 | 972 | |
973 | 973 | // if we'd pass -1 to LDAP search, we'd end up in a Protocol |
974 | 974 | // error. With a limit of 0, we get 0 results. So we pass null. |
975 | - if($limit <= 0) { |
|
975 | + if ($limit <= 0) { |
|
976 | 976 | $limit = null; |
977 | 977 | } |
978 | 978 | $filter = $this->access->combineFilterWithAnd(array( |
@@ -1004,7 +1004,7 @@ discard block |
||
1004 | 1004 | * (active directory has a limit of 1000 by default) |
1005 | 1005 | */ |
1006 | 1006 | public function getGroups($search = '', $limit = -1, $offset = 0) { |
1007 | - if(!$this->enabled) { |
|
1007 | + if (!$this->enabled) { |
|
1008 | 1008 | return array(); |
1009 | 1009 | } |
1010 | 1010 | $search = $this->access->escapeFilterPart($search, true); |
@@ -1051,20 +1051,20 @@ discard block |
||
1051 | 1051 | */ |
1052 | 1052 | public function groupExists($gid) { |
1053 | 1053 | $groupExists = $this->access->connection->getFromCache('groupExists'.$gid); |
1054 | - if(!is_null($groupExists)) { |
|
1055 | - return (bool)$groupExists; |
|
1054 | + if (!is_null($groupExists)) { |
|
1055 | + return (bool) $groupExists; |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | //getting dn, if false the group does not exist. If dn, it may be mapped |
1059 | 1059 | //only, requires more checking. |
1060 | 1060 | $dn = $this->access->groupname2dn($gid); |
1061 | - if(!$dn) { |
|
1061 | + if (!$dn) { |
|
1062 | 1062 | $this->access->connection->writeToCache('groupExists'.$gid, false); |
1063 | 1063 | return false; |
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | //if group really still exists, we will be able to read its objectclass |
1067 | - if(!is_array($this->access->readAttribute($dn, ''))) { |
|
1067 | + if (!is_array($this->access->readAttribute($dn, ''))) { |
|
1068 | 1068 | $this->access->connection->writeToCache('groupExists'.$gid, false); |
1069 | 1069 | return false; |
1070 | 1070 | } |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | * compared with OC_USER_BACKEND_CREATE_USER etc. |
1083 | 1083 | */ |
1084 | 1084 | public function implementsActions($actions) { |
1085 | - return (bool)(\OC\Group\Backend::COUNT_USERS & $actions); |
|
1085 | + return (bool) (\OC\Group\Backend::COUNT_USERS & $actions); |
|
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | public function __construct(Configuration $configuration, ILDAPWrapper $ldap, Access $access) { |
69 | 69 | parent::__construct($ldap); |
70 | 70 | $this->configuration = $configuration; |
71 | - if(is_null(Wizard::$l)) { |
|
71 | + if (is_null(Wizard::$l)) { |
|
72 | 72 | Wizard::$l = \OC::$server->getL10N('user_ldap'); |
73 | 73 | } |
74 | 74 | $this->access = $access; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | public function __destruct() { |
79 | - if($this->result->hasChanges()) { |
|
79 | + if ($this->result->hasChanges()) { |
|
80 | 80 | $this->configuration->saveConfiguration(); |
81 | 81 | } |
82 | 82 | } |
@@ -91,18 +91,18 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function countEntries($filter, $type) { |
93 | 93 | $reqs = array('ldapHost', 'ldapPort', 'ldapBase'); |
94 | - if($type === 'users') { |
|
94 | + if ($type === 'users') { |
|
95 | 95 | $reqs[] = 'ldapUserFilter'; |
96 | 96 | } |
97 | - if(!$this->checkRequirements($reqs)) { |
|
97 | + if (!$this->checkRequirements($reqs)) { |
|
98 | 98 | throw new \Exception('Requirements not met', 400); |
99 | 99 | } |
100 | 100 | |
101 | 101 | $attr = array('dn'); // default |
102 | 102 | $limit = 1001; |
103 | - if($type === 'groups') { |
|
104 | - $result = $this->access->countGroups($filter, $attr, $limit); |
|
105 | - } else if($type === 'users') { |
|
103 | + if ($type === 'groups') { |
|
104 | + $result = $this->access->countGroups($filter, $attr, $limit); |
|
105 | + } else if ($type === 'users') { |
|
106 | 106 | $result = $this->access->countUsers($filter, $attr, $limit); |
107 | 107 | } else if ($type === 'objects') { |
108 | 108 | $result = $this->access->countObjects($limit); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | private function formatCountResult($count) { |
124 | 124 | $formatted = ($count !== false) ? $count : 0; |
125 | - if($formatted > 1000) { |
|
125 | + if ($formatted > 1000) { |
|
126 | 126 | $formatted = '> 1000'; |
127 | 127 | } |
128 | 128 | return $formatted; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | public function countGroups() { |
132 | 132 | $filter = $this->configuration->ldapGroupFilter; |
133 | 133 | |
134 | - if(empty($filter)) { |
|
134 | + if (empty($filter)) { |
|
135 | 135 | $output = self::$l->n('%s group found', '%s groups found', 0, array(0)); |
136 | 136 | $this->result->addChange('ldap_group_count', $output); |
137 | 137 | return $this->result; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $groupsTotal = $this->formatCountResult($this->countEntries($filter, 'groups')); |
142 | 142 | } catch (\Exception $e) { |
143 | 143 | //400 can be ignored, 500 is forwarded |
144 | - if($e->getCode() === 500) { |
|
144 | + if ($e->getCode() === 500) { |
|
145 | 145 | throw $e; |
146 | 146 | } |
147 | 147 | return false; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | public function countInBaseDN() { |
174 | 174 | // we don't need to provide a filter in this case |
175 | 175 | $total = $this->countEntries(null, 'objects'); |
176 | - if($total === false) { |
|
176 | + if ($total === false) { |
|
177 | 177 | throw new \Exception('invalid results received'); |
178 | 178 | } |
179 | 179 | $this->result->addChange('ldap_test_base', $total); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @return int|bool |
188 | 188 | */ |
189 | 189 | public function countUsersWithAttribute($attr, $existsCheck = false) { |
190 | - if(!$this->checkRequirements(array('ldapHost', |
|
190 | + if (!$this->checkRequirements(array('ldapHost', |
|
191 | 191 | 'ldapPort', |
192 | 192 | 'ldapBase', |
193 | 193 | 'ldapUserFilter', |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | |
198 | 198 | $filter = $this->access->combineFilterWithAnd(array( |
199 | 199 | $this->configuration->ldapUserFilter, |
200 | - $attr . '=*' |
|
200 | + $attr.'=*' |
|
201 | 201 | )); |
202 | 202 | |
203 | 203 | $limit = ($existsCheck === false) ? null : 1; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @throws \Exception |
213 | 213 | */ |
214 | 214 | public function detectUserDisplayNameAttribute() { |
215 | - if(!$this->checkRequirements(array('ldapHost', |
|
215 | + if (!$this->checkRequirements(array('ldapHost', |
|
216 | 216 | 'ldapPort', |
217 | 217 | 'ldapBase', |
218 | 218 | 'ldapUserFilter', |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | // most likely not the default value with upper case N, |
226 | 226 | // verify it still produces a result |
227 | 227 | $count = intval($this->countUsersWithAttribute($attr, true)); |
228 | - if($count > 0) { |
|
228 | + if ($count > 0) { |
|
229 | 229 | //no change, but we sent it back to make sure the user interface |
230 | 230 | //is still correct, even if the ajax call was cancelled meanwhile |
231 | 231 | $this->result->addChange('ldap_display_name', $attr); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | foreach ($displayNameAttrs as $attr) { |
239 | 239 | $count = intval($this->countUsersWithAttribute($attr, true)); |
240 | 240 | |
241 | - if($count > 0) { |
|
241 | + if ($count > 0) { |
|
242 | 242 | $this->applyFind('ldap_display_name', $attr); |
243 | 243 | return $this->result; |
244 | 244 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * @return WizardResult|bool |
255 | 255 | */ |
256 | 256 | public function detectEmailAttribute() { |
257 | - if(!$this->checkRequirements(array('ldapHost', |
|
257 | + if (!$this->checkRequirements(array('ldapHost', |
|
258 | 258 | 'ldapPort', |
259 | 259 | 'ldapBase', |
260 | 260 | 'ldapUserFilter', |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | $attr = $this->configuration->ldapEmailAttribute; |
266 | 266 | if ($attr !== '') { |
267 | 267 | $count = intval($this->countUsersWithAttribute($attr, true)); |
268 | - if($count > 0) { |
|
268 | + if ($count > 0) { |
|
269 | 269 | return false; |
270 | 270 | } |
271 | 271 | $writeLog = true; |
@@ -276,19 +276,19 @@ discard block |
||
276 | 276 | $emailAttributes = array('mail', 'mailPrimaryAddress'); |
277 | 277 | $winner = ''; |
278 | 278 | $maxUsers = 0; |
279 | - foreach($emailAttributes as $attr) { |
|
279 | + foreach ($emailAttributes as $attr) { |
|
280 | 280 | $count = $this->countUsersWithAttribute($attr); |
281 | - if($count > $maxUsers) { |
|
281 | + if ($count > $maxUsers) { |
|
282 | 282 | $maxUsers = $count; |
283 | 283 | $winner = $attr; |
284 | 284 | } |
285 | 285 | } |
286 | 286 | |
287 | - if($winner !== '') { |
|
287 | + if ($winner !== '') { |
|
288 | 288 | $this->applyFind('ldap_email_attr', $winner); |
289 | - if($writeLog) { |
|
290 | - \OCP\Util::writeLog('user_ldap', 'The mail attribute has ' . |
|
291 | - 'automatically been reset, because the original value ' . |
|
289 | + if ($writeLog) { |
|
290 | + \OCP\Util::writeLog('user_ldap', 'The mail attribute has '. |
|
291 | + 'automatically been reset, because the original value '. |
|
292 | 292 | 'did not return any results.', \OCP\Util::INFO); |
293 | 293 | } |
294 | 294 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @throws \Exception |
302 | 302 | */ |
303 | 303 | public function determineAttributes() { |
304 | - if(!$this->checkRequirements(array('ldapHost', |
|
304 | + if (!$this->checkRequirements(array('ldapHost', |
|
305 | 305 | 'ldapPort', |
306 | 306 | 'ldapBase', |
307 | 307 | 'ldapUserFilter', |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | $this->result->addOptions('ldap_loginfilter_attributes', $attributes); |
318 | 318 | |
319 | 319 | $selected = $this->configuration->ldapLoginFilterAttributes; |
320 | - if(is_array($selected) && !empty($selected)) { |
|
320 | + if (is_array($selected) && !empty($selected)) { |
|
321 | 321 | $this->result->addChange('ldap_loginfilter_attributes', $selected); |
322 | 322 | } |
323 | 323 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * @throws \Exception |
331 | 331 | */ |
332 | 332 | private function getUserAttributes() { |
333 | - if(!$this->checkRequirements(array('ldapHost', |
|
333 | + if (!$this->checkRequirements(array('ldapHost', |
|
334 | 334 | 'ldapPort', |
335 | 335 | 'ldapBase', |
336 | 336 | 'ldapUserFilter', |
@@ -338,20 +338,20 @@ discard block |
||
338 | 338 | return false; |
339 | 339 | } |
340 | 340 | $cr = $this->getConnection(); |
341 | - if(!$cr) { |
|
341 | + if (!$cr) { |
|
342 | 342 | throw new \Exception('Could not connect to LDAP'); |
343 | 343 | } |
344 | 344 | |
345 | 345 | $base = $this->configuration->ldapBase[0]; |
346 | 346 | $filter = $this->configuration->ldapUserFilter; |
347 | 347 | $rr = $this->ldap->search($cr, $base, $filter, array(), 1, 1); |
348 | - if(!$this->ldap->isResource($rr)) { |
|
348 | + if (!$this->ldap->isResource($rr)) { |
|
349 | 349 | return false; |
350 | 350 | } |
351 | 351 | $er = $this->ldap->firstEntry($cr, $rr); |
352 | 352 | $attributes = $this->ldap->getAttributes($cr, $er); |
353 | 353 | $pureAttributes = array(); |
354 | - for($i = 0; $i < $attributes['count']; $i++) { |
|
354 | + for ($i = 0; $i < $attributes['count']; $i++) { |
|
355 | 355 | $pureAttributes[] = $attributes[$i]; |
356 | 356 | } |
357 | 357 | |
@@ -386,23 +386,23 @@ discard block |
||
386 | 386 | * @throws \Exception |
387 | 387 | */ |
388 | 388 | private function determineGroups($dbKey, $confKey, $testMemberOf = true) { |
389 | - if(!$this->checkRequirements(array('ldapHost', |
|
389 | + if (!$this->checkRequirements(array('ldapHost', |
|
390 | 390 | 'ldapPort', |
391 | 391 | 'ldapBase', |
392 | 392 | ))) { |
393 | 393 | return false; |
394 | 394 | } |
395 | 395 | $cr = $this->getConnection(); |
396 | - if(!$cr) { |
|
396 | + if (!$cr) { |
|
397 | 397 | throw new \Exception('Could not connect to LDAP'); |
398 | 398 | } |
399 | 399 | |
400 | 400 | $this->fetchGroups($dbKey, $confKey); |
401 | 401 | |
402 | - if($testMemberOf) { |
|
402 | + if ($testMemberOf) { |
|
403 | 403 | $this->configuration->hasMemberOfFilterSupport = $this->testMemberOf(); |
404 | 404 | $this->result->markChange(); |
405 | - if(!$this->configuration->hasMemberOfFilterSupport) { |
|
405 | + if (!$this->configuration->hasMemberOfFilterSupport) { |
|
406 | 406 | throw new \Exception('memberOf is not supported by the server'); |
407 | 407 | } |
408 | 408 | } |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | $obclasses = array('posixGroup', 'group', 'zimbraDistributionList', 'groupOfNames'); |
423 | 423 | |
424 | 424 | $filterParts = array(); |
425 | - foreach($obclasses as $obclass) { |
|
425 | + foreach ($obclasses as $obclass) { |
|
426 | 426 | $filterParts[] = 'objectclass='.$obclass; |
427 | 427 | } |
428 | 428 | //we filter for everything |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | // we need to request dn additionally here, otherwise memberOf |
440 | 440 | // detection will fail later |
441 | 441 | $result = $this->access->searchGroups($filter, array('cn', 'dn'), $limit, $offset); |
442 | - foreach($result as $item) { |
|
443 | - if(!isset($item['cn']) && !is_array($item['cn']) && !isset($item['cn'][0])) { |
|
442 | + foreach ($result as $item) { |
|
443 | + if (!isset($item['cn']) && !is_array($item['cn']) && !isset($item['cn'][0])) { |
|
444 | 444 | // just in case - no issue known |
445 | 445 | continue; |
446 | 446 | } |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | $offset += $limit; |
451 | 451 | } while ($this->access->hasMoreResults()); |
452 | 452 | |
453 | - if(count($groupNames) > 0) { |
|
453 | + if (count($groupNames) > 0) { |
|
454 | 454 | natsort($groupNames); |
455 | 455 | $this->result->addOptions($dbKey, array_values($groupNames)); |
456 | 456 | } else { |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | } |
459 | 459 | |
460 | 460 | $setFeatures = $this->configuration->$confKey; |
461 | - if(is_array($setFeatures) && !empty($setFeatures)) { |
|
461 | + if (is_array($setFeatures) && !empty($setFeatures)) { |
|
462 | 462 | //something is already configured? pre-select it. |
463 | 463 | $this->result->addChange($dbKey, $setFeatures); |
464 | 464 | } |
@@ -466,14 +466,14 @@ discard block |
||
466 | 466 | } |
467 | 467 | |
468 | 468 | public function determineGroupMemberAssoc() { |
469 | - if(!$this->checkRequirements(array('ldapHost', |
|
469 | + if (!$this->checkRequirements(array('ldapHost', |
|
470 | 470 | 'ldapPort', |
471 | 471 | 'ldapGroupFilter', |
472 | 472 | ))) { |
473 | 473 | return false; |
474 | 474 | } |
475 | 475 | $attribute = $this->detectGroupMemberAssoc(); |
476 | - if($attribute === false) { |
|
476 | + if ($attribute === false) { |
|
477 | 477 | return false; |
478 | 478 | } |
479 | 479 | $this->configuration->setConfiguration(array('ldapGroupMemberAssocAttr' => $attribute)); |
@@ -488,14 +488,14 @@ discard block |
||
488 | 488 | * @throws \Exception |
489 | 489 | */ |
490 | 490 | public function determineGroupObjectClasses() { |
491 | - if(!$this->checkRequirements(array('ldapHost', |
|
491 | + if (!$this->checkRequirements(array('ldapHost', |
|
492 | 492 | 'ldapPort', |
493 | 493 | 'ldapBase', |
494 | 494 | ))) { |
495 | 495 | return false; |
496 | 496 | } |
497 | 497 | $cr = $this->getConnection(); |
498 | - if(!$cr) { |
|
498 | + if (!$cr) { |
|
499 | 499 | throw new \Exception('Could not connect to LDAP'); |
500 | 500 | } |
501 | 501 | |
@@ -515,14 +515,14 @@ discard block |
||
515 | 515 | * @throws \Exception |
516 | 516 | */ |
517 | 517 | public function determineUserObjectClasses() { |
518 | - if(!$this->checkRequirements(array('ldapHost', |
|
518 | + if (!$this->checkRequirements(array('ldapHost', |
|
519 | 519 | 'ldapPort', |
520 | 520 | 'ldapBase', |
521 | 521 | ))) { |
522 | 522 | return false; |
523 | 523 | } |
524 | 524 | $cr = $this->getConnection(); |
525 | - if(!$cr) { |
|
525 | + if (!$cr) { |
|
526 | 526 | throw new \Exception('Could not connect to LDAP'); |
527 | 527 | } |
528 | 528 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * @throws \Exception |
546 | 546 | */ |
547 | 547 | public function getGroupFilter() { |
548 | - if(!$this->checkRequirements(array('ldapHost', |
|
548 | + if (!$this->checkRequirements(array('ldapHost', |
|
549 | 549 | 'ldapPort', |
550 | 550 | 'ldapBase', |
551 | 551 | ))) { |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | * @throws \Exception |
570 | 570 | */ |
571 | 571 | public function getUserListFilter() { |
572 | - if(!$this->checkRequirements(array('ldapHost', |
|
572 | + if (!$this->checkRequirements(array('ldapHost', |
|
573 | 573 | 'ldapPort', |
574 | 574 | 'ldapBase', |
575 | 575 | ))) { |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | $this->applyFind('ldap_display_name', $d['ldap_display_name']); |
583 | 583 | } |
584 | 584 | $filter = $this->composeLdapFilter(self::LFILTER_USER_LIST); |
585 | - if(!$filter) { |
|
585 | + if (!$filter) { |
|
586 | 586 | throw new \Exception('Cannot create filter'); |
587 | 587 | } |
588 | 588 | |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | * @throws \Exception |
596 | 596 | */ |
597 | 597 | public function getUserLoginFilter() { |
598 | - if(!$this->checkRequirements(array('ldapHost', |
|
598 | + if (!$this->checkRequirements(array('ldapHost', |
|
599 | 599 | 'ldapPort', |
600 | 600 | 'ldapBase', |
601 | 601 | 'ldapUserFilter', |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | } |
605 | 605 | |
606 | 606 | $filter = $this->composeLdapFilter(self::LFILTER_LOGIN); |
607 | - if(!$filter) { |
|
607 | + if (!$filter) { |
|
608 | 608 | throw new \Exception('Cannot create filter'); |
609 | 609 | } |
610 | 610 | |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | * @throws \Exception |
619 | 619 | */ |
620 | 620 | public function testLoginName($loginName) { |
621 | - if(!$this->checkRequirements(array('ldapHost', |
|
621 | + if (!$this->checkRequirements(array('ldapHost', |
|
622 | 622 | 'ldapPort', |
623 | 623 | 'ldapBase', |
624 | 624 | 'ldapLoginFilter', |
@@ -627,17 +627,17 @@ discard block |
||
627 | 627 | } |
628 | 628 | |
629 | 629 | $cr = $this->access->connection->getConnectionResource(); |
630 | - if(!$this->ldap->isResource($cr)) { |
|
630 | + if (!$this->ldap->isResource($cr)) { |
|
631 | 631 | throw new \Exception('connection error'); |
632 | 632 | } |
633 | 633 | |
634 | - if(mb_strpos($this->access->connection->ldapLoginFilter, '%uid', 0, 'UTF-8') |
|
634 | + if (mb_strpos($this->access->connection->ldapLoginFilter, '%uid', 0, 'UTF-8') |
|
635 | 635 | === false) { |
636 | 636 | throw new \Exception('missing placeholder'); |
637 | 637 | } |
638 | 638 | |
639 | 639 | $users = $this->access->countUsersByLoginName($loginName); |
640 | - if($this->ldap->errno($cr) !== 0) { |
|
640 | + if ($this->ldap->errno($cr) !== 0) { |
|
641 | 641 | throw new \Exception($this->ldap->error($cr)); |
642 | 642 | } |
643 | 643 | $filter = str_replace('%uid', $loginName, $this->access->connection->ldapLoginFilter); |
@@ -652,22 +652,22 @@ discard block |
||
652 | 652 | * @throws \Exception |
653 | 653 | */ |
654 | 654 | public function guessPortAndTLS() { |
655 | - if(!$this->checkRequirements(array('ldapHost', |
|
655 | + if (!$this->checkRequirements(array('ldapHost', |
|
656 | 656 | ))) { |
657 | 657 | return false; |
658 | 658 | } |
659 | 659 | $this->checkHost(); |
660 | 660 | $portSettings = $this->getPortSettingsToTry(); |
661 | 661 | |
662 | - if(!is_array($portSettings)) { |
|
662 | + if (!is_array($portSettings)) { |
|
663 | 663 | throw new \Exception(print_r($portSettings, true)); |
664 | 664 | } |
665 | 665 | |
666 | 666 | //proceed from the best configuration and return on first success |
667 | - foreach($portSettings as $setting) { |
|
667 | + foreach ($portSettings as $setting) { |
|
668 | 668 | $p = $setting['port']; |
669 | 669 | $t = $setting['tls']; |
670 | - \OCP\Util::writeLog('user_ldap', 'Wiz: trying port '. $p . ', TLS '. $t, \OCP\Util::DEBUG); |
|
670 | + \OCP\Util::writeLog('user_ldap', 'Wiz: trying port '.$p.', TLS '.$t, \OCP\Util::DEBUG); |
|
671 | 671 | //connectAndBind may throw Exception, it needs to be catched by the |
672 | 672 | //callee of this method |
673 | 673 | |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | // any reply other than -1 (= cannot connect) is already okay, |
678 | 678 | // because then we found the server |
679 | 679 | // unavailable startTLS returns -11 |
680 | - if($e->getCode() > 0) { |
|
680 | + if ($e->getCode() > 0) { |
|
681 | 681 | $settingsFound = true; |
682 | 682 | } else { |
683 | 683 | throw $e; |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | 'ldapTLS' => intval($t) |
691 | 691 | ); |
692 | 692 | $this->configuration->setConfiguration($config); |
693 | - \OCP\Util::writeLog('user_ldap', 'Wiz: detected Port ' . $p, \OCP\Util::DEBUG); |
|
693 | + \OCP\Util::writeLog('user_ldap', 'Wiz: detected Port '.$p, \OCP\Util::DEBUG); |
|
694 | 694 | $this->result->addChange('ldap_port', $p); |
695 | 695 | return $this->result; |
696 | 696 | } |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | * @return WizardResult|false WizardResult on success, false otherwise |
706 | 706 | */ |
707 | 707 | public function guessBaseDN() { |
708 | - if(!$this->checkRequirements(array('ldapHost', |
|
708 | + if (!$this->checkRequirements(array('ldapHost', |
|
709 | 709 | 'ldapPort', |
710 | 710 | ))) { |
711 | 711 | return false; |
@@ -714,9 +714,9 @@ discard block |
||
714 | 714 | //check whether a DN is given in the agent name (99.9% of all cases) |
715 | 715 | $base = null; |
716 | 716 | $i = stripos($this->configuration->ldapAgentName, 'dc='); |
717 | - if($i !== false) { |
|
717 | + if ($i !== false) { |
|
718 | 718 | $base = substr($this->configuration->ldapAgentName, $i); |
719 | - if($this->testBaseDN($base)) { |
|
719 | + if ($this->testBaseDN($base)) { |
|
720 | 720 | $this->applyFind('ldap_base', $base); |
721 | 721 | return $this->result; |
722 | 722 | } |
@@ -727,13 +727,13 @@ discard block |
||
727 | 727 | //a base DN |
728 | 728 | $helper = new Helper(\OC::$server->getConfig()); |
729 | 729 | $domain = $helper->getDomainFromURL($this->configuration->ldapHost); |
730 | - if(!$domain) { |
|
730 | + if (!$domain) { |
|
731 | 731 | return false; |
732 | 732 | } |
733 | 733 | |
734 | 734 | $dparts = explode('.', $domain); |
735 | - while(count($dparts) > 0) { |
|
736 | - $base2 = 'dc=' . implode(',dc=', $dparts); |
|
735 | + while (count($dparts) > 0) { |
|
736 | + $base2 = 'dc='.implode(',dc=', $dparts); |
|
737 | 737 | if ($base !== $base2 && $this->testBaseDN($base2)) { |
738 | 738 | $this->applyFind('ldap_base', $base2); |
739 | 739 | return $this->result; |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | $hostInfo = parse_url($host); |
767 | 767 | |
768 | 768 | //removes Port from Host |
769 | - if(is_array($hostInfo) && isset($hostInfo['port'])) { |
|
769 | + if (is_array($hostInfo) && isset($hostInfo['port'])) { |
|
770 | 770 | $port = $hostInfo['port']; |
771 | 771 | $host = str_replace(':'.$port, '', $host); |
772 | 772 | $this->applyFind('ldap_host', $host); |
@@ -783,30 +783,30 @@ discard block |
||
783 | 783 | private function detectGroupMemberAssoc() { |
784 | 784 | $possibleAttrs = array('uniqueMember', 'memberUid', 'member', 'gidNumber'); |
785 | 785 | $filter = $this->configuration->ldapGroupFilter; |
786 | - if(empty($filter)) { |
|
786 | + if (empty($filter)) { |
|
787 | 787 | return false; |
788 | 788 | } |
789 | 789 | $cr = $this->getConnection(); |
790 | - if(!$cr) { |
|
790 | + if (!$cr) { |
|
791 | 791 | throw new \Exception('Could not connect to LDAP'); |
792 | 792 | } |
793 | 793 | $base = $this->configuration->ldapBase[0]; |
794 | 794 | $rr = $this->ldap->search($cr, $base, $filter, $possibleAttrs, 0, 1000); |
795 | - if(!$this->ldap->isResource($rr)) { |
|
795 | + if (!$this->ldap->isResource($rr)) { |
|
796 | 796 | return false; |
797 | 797 | } |
798 | 798 | $er = $this->ldap->firstEntry($cr, $rr); |
799 | - while(is_resource($er)) { |
|
799 | + while (is_resource($er)) { |
|
800 | 800 | $this->ldap->getDN($cr, $er); |
801 | 801 | $attrs = $this->ldap->getAttributes($cr, $er); |
802 | 802 | $result = array(); |
803 | 803 | $possibleAttrsCount = count($possibleAttrs); |
804 | - for($i = 0; $i < $possibleAttrsCount; $i++) { |
|
805 | - if(isset($attrs[$possibleAttrs[$i]])) { |
|
804 | + for ($i = 0; $i < $possibleAttrsCount; $i++) { |
|
805 | + if (isset($attrs[$possibleAttrs[$i]])) { |
|
806 | 806 | $result[$possibleAttrs[$i]] = $attrs[$possibleAttrs[$i]]['count']; |
807 | 807 | } |
808 | 808 | } |
809 | - if(!empty($result)) { |
|
809 | + if (!empty($result)) { |
|
810 | 810 | natsort($result); |
811 | 811 | return key($result); |
812 | 812 | } |
@@ -825,14 +825,14 @@ discard block |
||
825 | 825 | */ |
826 | 826 | private function testBaseDN($base) { |
827 | 827 | $cr = $this->getConnection(); |
828 | - if(!$cr) { |
|
828 | + if (!$cr) { |
|
829 | 829 | throw new \Exception('Could not connect to LDAP'); |
830 | 830 | } |
831 | 831 | |
832 | 832 | //base is there, let's validate it. If we search for anything, we should |
833 | 833 | //get a result set > 0 on a proper base |
834 | 834 | $rr = $this->ldap->search($cr, $base, 'objectClass=*', array('dn'), 0, 1); |
835 | - if(!$this->ldap->isResource($rr)) { |
|
835 | + if (!$this->ldap->isResource($rr)) { |
|
836 | 836 | $errorNo = $this->ldap->errno($cr); |
837 | 837 | $errorMsg = $this->ldap->error($cr); |
838 | 838 | \OCP\Util::writeLog('user_ldap', 'Wiz: Could not search base '.$base. |
@@ -854,11 +854,11 @@ discard block |
||
854 | 854 | */ |
855 | 855 | private function testMemberOf() { |
856 | 856 | $cr = $this->getConnection(); |
857 | - if(!$cr) { |
|
857 | + if (!$cr) { |
|
858 | 858 | throw new \Exception('Could not connect to LDAP'); |
859 | 859 | } |
860 | 860 | $result = $this->access->countUsers('memberOf=*', array('memberOf'), 1); |
861 | - if(is_int($result) && $result > 0) { |
|
861 | + if (is_int($result) && $result > 0) { |
|
862 | 862 | return true; |
863 | 863 | } |
864 | 864 | return false; |
@@ -879,27 +879,27 @@ discard block |
||
879 | 879 | case self::LFILTER_USER_LIST: |
880 | 880 | $objcs = $this->configuration->ldapUserFilterObjectclass; |
881 | 881 | //glue objectclasses |
882 | - if(is_array($objcs) && count($objcs) > 0) { |
|
882 | + if (is_array($objcs) && count($objcs) > 0) { |
|
883 | 883 | $filter .= '(|'; |
884 | - foreach($objcs as $objc) { |
|
885 | - $filter .= '(objectclass=' . $objc . ')'; |
|
884 | + foreach ($objcs as $objc) { |
|
885 | + $filter .= '(objectclass='.$objc.')'; |
|
886 | 886 | } |
887 | 887 | $filter .= ')'; |
888 | 888 | $parts++; |
889 | 889 | } |
890 | 890 | //glue group memberships |
891 | - if($this->configuration->hasMemberOfFilterSupport) { |
|
891 | + if ($this->configuration->hasMemberOfFilterSupport) { |
|
892 | 892 | $cns = $this->configuration->ldapUserFilterGroups; |
893 | - if(is_array($cns) && count($cns) > 0) { |
|
893 | + if (is_array($cns) && count($cns) > 0) { |
|
894 | 894 | $filter .= '(|'; |
895 | 895 | $cr = $this->getConnection(); |
896 | - if(!$cr) { |
|
896 | + if (!$cr) { |
|
897 | 897 | throw new \Exception('Could not connect to LDAP'); |
898 | 898 | } |
899 | 899 | $base = $this->configuration->ldapBase[0]; |
900 | - foreach($cns as $cn) { |
|
901 | - $rr = $this->ldap->search($cr, $base, 'cn=' . $cn, array('dn', 'primaryGroupToken')); |
|
902 | - if(!$this->ldap->isResource($rr)) { |
|
900 | + foreach ($cns as $cn) { |
|
901 | + $rr = $this->ldap->search($cr, $base, 'cn='.$cn, array('dn', 'primaryGroupToken')); |
|
902 | + if (!$this->ldap->isResource($rr)) { |
|
903 | 903 | continue; |
904 | 904 | } |
905 | 905 | $er = $this->ldap->firstEntry($cr, $rr); |
@@ -908,11 +908,11 @@ discard block |
||
908 | 908 | if ($dn == false || $dn === '') { |
909 | 909 | continue; |
910 | 910 | } |
911 | - $filterPart = '(memberof=' . $dn . ')'; |
|
912 | - if(isset($attrs['primaryGroupToken'])) { |
|
911 | + $filterPart = '(memberof='.$dn.')'; |
|
912 | + if (isset($attrs['primaryGroupToken'])) { |
|
913 | 913 | $pgt = $attrs['primaryGroupToken'][0]; |
914 | - $primaryFilterPart = '(primaryGroupID=' . $pgt .')'; |
|
915 | - $filterPart = '(|' . $filterPart . $primaryFilterPart . ')'; |
|
914 | + $primaryFilterPart = '(primaryGroupID='.$pgt.')'; |
|
915 | + $filterPart = '(|'.$filterPart.$primaryFilterPart.')'; |
|
916 | 916 | } |
917 | 917 | $filter .= $filterPart; |
918 | 918 | } |
@@ -921,8 +921,8 @@ discard block |
||
921 | 921 | $parts++; |
922 | 922 | } |
923 | 923 | //wrap parts in AND condition |
924 | - if($parts > 1) { |
|
925 | - $filter = '(&' . $filter . ')'; |
|
924 | + if ($parts > 1) { |
|
925 | + $filter = '(&'.$filter.')'; |
|
926 | 926 | } |
927 | 927 | if ($filter === '') { |
928 | 928 | $filter = '(objectclass=*)'; |
@@ -932,27 +932,27 @@ discard block |
||
932 | 932 | case self::LFILTER_GROUP_LIST: |
933 | 933 | $objcs = $this->configuration->ldapGroupFilterObjectclass; |
934 | 934 | //glue objectclasses |
935 | - if(is_array($objcs) && count($objcs) > 0) { |
|
935 | + if (is_array($objcs) && count($objcs) > 0) { |
|
936 | 936 | $filter .= '(|'; |
937 | - foreach($objcs as $objc) { |
|
938 | - $filter .= '(objectclass=' . $objc . ')'; |
|
937 | + foreach ($objcs as $objc) { |
|
938 | + $filter .= '(objectclass='.$objc.')'; |
|
939 | 939 | } |
940 | 940 | $filter .= ')'; |
941 | 941 | $parts++; |
942 | 942 | } |
943 | 943 | //glue group memberships |
944 | 944 | $cns = $this->configuration->ldapGroupFilterGroups; |
945 | - if(is_array($cns) && count($cns) > 0) { |
|
945 | + if (is_array($cns) && count($cns) > 0) { |
|
946 | 946 | $filter .= '(|'; |
947 | - foreach($cns as $cn) { |
|
948 | - $filter .= '(cn=' . $cn . ')'; |
|
947 | + foreach ($cns as $cn) { |
|
948 | + $filter .= '(cn='.$cn.')'; |
|
949 | 949 | } |
950 | 950 | $filter .= ')'; |
951 | 951 | } |
952 | 952 | $parts++; |
953 | 953 | //wrap parts in AND condition |
954 | - if($parts > 1) { |
|
955 | - $filter = '(&' . $filter . ')'; |
|
954 | + if ($parts > 1) { |
|
955 | + $filter = '(&'.$filter.')'; |
|
956 | 956 | } |
957 | 957 | break; |
958 | 958 | |
@@ -964,47 +964,47 @@ discard block |
||
964 | 964 | $userAttributes = array_change_key_case(array_flip($userAttributes)); |
965 | 965 | $parts = 0; |
966 | 966 | |
967 | - if($this->configuration->ldapLoginFilterUsername === '1') { |
|
967 | + if ($this->configuration->ldapLoginFilterUsername === '1') { |
|
968 | 968 | $attr = ''; |
969 | - if(isset($userAttributes['uid'])) { |
|
969 | + if (isset($userAttributes['uid'])) { |
|
970 | 970 | $attr = 'uid'; |
971 | - } else if(isset($userAttributes['samaccountname'])) { |
|
971 | + } else if (isset($userAttributes['samaccountname'])) { |
|
972 | 972 | $attr = 'samaccountname'; |
973 | - } else if(isset($userAttributes['cn'])) { |
|
973 | + } else if (isset($userAttributes['cn'])) { |
|
974 | 974 | //fallback |
975 | 975 | $attr = 'cn'; |
976 | 976 | } |
977 | 977 | if ($attr !== '') { |
978 | - $filterUsername = '(' . $attr . $loginpart . ')'; |
|
978 | + $filterUsername = '('.$attr.$loginpart.')'; |
|
979 | 979 | $parts++; |
980 | 980 | } |
981 | 981 | } |
982 | 982 | |
983 | 983 | $filterEmail = ''; |
984 | - if($this->configuration->ldapLoginFilterEmail === '1') { |
|
984 | + if ($this->configuration->ldapLoginFilterEmail === '1') { |
|
985 | 985 | $filterEmail = '(|(mailPrimaryAddress=%uid)(mail=%uid))'; |
986 | 986 | $parts++; |
987 | 987 | } |
988 | 988 | |
989 | 989 | $filterAttributes = ''; |
990 | 990 | $attrsToFilter = $this->configuration->ldapLoginFilterAttributes; |
991 | - if(is_array($attrsToFilter) && count($attrsToFilter) > 0) { |
|
991 | + if (is_array($attrsToFilter) && count($attrsToFilter) > 0) { |
|
992 | 992 | $filterAttributes = '(|'; |
993 | - foreach($attrsToFilter as $attribute) { |
|
994 | - $filterAttributes .= '(' . $attribute . $loginpart . ')'; |
|
993 | + foreach ($attrsToFilter as $attribute) { |
|
994 | + $filterAttributes .= '('.$attribute.$loginpart.')'; |
|
995 | 995 | } |
996 | 996 | $filterAttributes .= ')'; |
997 | 997 | $parts++; |
998 | 998 | } |
999 | 999 | |
1000 | 1000 | $filterLogin = ''; |
1001 | - if($parts > 1) { |
|
1001 | + if ($parts > 1) { |
|
1002 | 1002 | $filterLogin = '(|'; |
1003 | 1003 | } |
1004 | 1004 | $filterLogin .= $filterUsername; |
1005 | 1005 | $filterLogin .= $filterEmail; |
1006 | 1006 | $filterLogin .= $filterAttributes; |
1007 | - if($parts > 1) { |
|
1007 | + if ($parts > 1) { |
|
1008 | 1008 | $filterLogin .= ')'; |
1009 | 1009 | } |
1010 | 1010 | |
@@ -1026,7 +1026,7 @@ discard block |
||
1026 | 1026 | * @throws \Exception |
1027 | 1027 | */ |
1028 | 1028 | private function connectAndBind($port = 389, $tls = false, $ncc = false) { |
1029 | - if($ncc) { |
|
1029 | + if ($ncc) { |
|
1030 | 1030 | //No certificate check |
1031 | 1031 | //FIXME: undo afterwards |
1032 | 1032 | putenv('LDAPTLS_REQCERT=never'); |
@@ -1036,12 +1036,12 @@ discard block |
||
1036 | 1036 | \OCP\Util::writeLog('user_ldap', 'Wiz: Checking Host Info ', \OCP\Util::DEBUG); |
1037 | 1037 | $host = $this->configuration->ldapHost; |
1038 | 1038 | $hostInfo = parse_url($host); |
1039 | - if(!$hostInfo) { |
|
1039 | + if (!$hostInfo) { |
|
1040 | 1040 | throw new \Exception(self::$l->t('Invalid Host')); |
1041 | 1041 | } |
1042 | 1042 | \OCP\Util::writeLog('user_ldap', 'Wiz: Attempting to connect ', \OCP\Util::DEBUG); |
1043 | 1043 | $cr = $this->ldap->connect($host, $port); |
1044 | - if(!is_resource($cr)) { |
|
1044 | + if (!is_resource($cr)) { |
|
1045 | 1045 | throw new \Exception(self::$l->t('Invalid Host')); |
1046 | 1046 | } |
1047 | 1047 | |
@@ -1052,9 +1052,9 @@ discard block |
||
1052 | 1052 | $this->ldap->setOption($cr, LDAP_OPT_NETWORK_TIMEOUT, self::LDAP_NW_TIMEOUT); |
1053 | 1053 | |
1054 | 1054 | try { |
1055 | - if($tls) { |
|
1055 | + if ($tls) { |
|
1056 | 1056 | $isTlsWorking = @$this->ldap->startTls($cr); |
1057 | - if(!$isTlsWorking) { |
|
1057 | + if (!$isTlsWorking) { |
|
1058 | 1058 | return false; |
1059 | 1059 | } |
1060 | 1060 | } |
@@ -1068,20 +1068,20 @@ discard block |
||
1068 | 1068 | $errNo = $this->ldap->errno($cr); |
1069 | 1069 | $error = ldap_error($cr); |
1070 | 1070 | $this->ldap->unbind($cr); |
1071 | - } catch(ServerNotAvailableException $e) { |
|
1071 | + } catch (ServerNotAvailableException $e) { |
|
1072 | 1072 | return false; |
1073 | 1073 | } |
1074 | 1074 | |
1075 | - if($login === true) { |
|
1075 | + if ($login === true) { |
|
1076 | 1076 | $this->ldap->unbind($cr); |
1077 | - if($ncc) { |
|
1077 | + if ($ncc) { |
|
1078 | 1078 | throw new \Exception('Certificate cannot be validated.'); |
1079 | 1079 | } |
1080 | - \OCP\Util::writeLog('user_ldap', 'Wiz: Bind successful to Port '. $port . ' TLS ' . intval($tls), \OCP\Util::DEBUG); |
|
1080 | + \OCP\Util::writeLog('user_ldap', 'Wiz: Bind successful to Port '.$port.' TLS '.intval($tls), \OCP\Util::DEBUG); |
|
1081 | 1081 | return true; |
1082 | 1082 | } |
1083 | 1083 | |
1084 | - if($errNo === -1 || ($errNo === 2 && $ncc)) { |
|
1084 | + if ($errNo === -1 || ($errNo === 2 && $ncc)) { |
|
1085 | 1085 | //host, port or TLS wrong |
1086 | 1086 | return false; |
1087 | 1087 | } else if ($errNo === 2) { |
@@ -1111,9 +1111,9 @@ discard block |
||
1111 | 1111 | */ |
1112 | 1112 | private function checkRequirements($reqs) { |
1113 | 1113 | $this->checkAgentRequirements(); |
1114 | - foreach($reqs as $option) { |
|
1114 | + foreach ($reqs as $option) { |
|
1115 | 1115 | $value = $this->configuration->$option; |
1116 | - if(empty($value)) { |
|
1116 | + if (empty($value)) { |
|
1117 | 1117 | return false; |
1118 | 1118 | } |
1119 | 1119 | } |
@@ -1135,33 +1135,33 @@ discard block |
||
1135 | 1135 | $dnRead = array(); |
1136 | 1136 | $foundItems = array(); |
1137 | 1137 | $maxEntries = 0; |
1138 | - if(!is_array($this->configuration->ldapBase) |
|
1138 | + if (!is_array($this->configuration->ldapBase) |
|
1139 | 1139 | || !isset($this->configuration->ldapBase[0])) { |
1140 | 1140 | return false; |
1141 | 1141 | } |
1142 | 1142 | $base = $this->configuration->ldapBase[0]; |
1143 | 1143 | $cr = $this->getConnection(); |
1144 | - if(!$this->ldap->isResource($cr)) { |
|
1144 | + if (!$this->ldap->isResource($cr)) { |
|
1145 | 1145 | return false; |
1146 | 1146 | } |
1147 | 1147 | $lastFilter = null; |
1148 | - if(isset($filters[count($filters)-1])) { |
|
1149 | - $lastFilter = $filters[count($filters)-1]; |
|
1148 | + if (isset($filters[count($filters) - 1])) { |
|
1149 | + $lastFilter = $filters[count($filters) - 1]; |
|
1150 | 1150 | } |
1151 | - foreach($filters as $filter) { |
|
1152 | - if($lastFilter === $filter && count($foundItems) > 0) { |
|
1151 | + foreach ($filters as $filter) { |
|
1152 | + if ($lastFilter === $filter && count($foundItems) > 0) { |
|
1153 | 1153 | //skip when the filter is a wildcard and results were found |
1154 | 1154 | continue; |
1155 | 1155 | } |
1156 | 1156 | // 20k limit for performance and reason |
1157 | 1157 | $rr = $this->ldap->search($cr, $base, $filter, array($attr), 0, 20000); |
1158 | - if(!$this->ldap->isResource($rr)) { |
|
1158 | + if (!$this->ldap->isResource($rr)) { |
|
1159 | 1159 | continue; |
1160 | 1160 | } |
1161 | 1161 | $entries = $this->ldap->countEntries($cr, $rr); |
1162 | 1162 | $getEntryFunc = 'firstEntry'; |
1163 | - if(($entries !== false) && ($entries > 0)) { |
|
1164 | - if(!is_null($maxF) && $entries > $maxEntries) { |
|
1163 | + if (($entries !== false) && ($entries > 0)) { |
|
1164 | + if (!is_null($maxF) && $entries > $maxEntries) { |
|
1165 | 1165 | $maxEntries = $entries; |
1166 | 1166 | $maxF = $filter; |
1167 | 1167 | } |
@@ -1169,13 +1169,13 @@ discard block |
||
1169 | 1169 | do { |
1170 | 1170 | $entry = $this->ldap->$getEntryFunc($cr, $rr); |
1171 | 1171 | $getEntryFunc = 'nextEntry'; |
1172 | - if(!$this->ldap->isResource($entry)) { |
|
1172 | + if (!$this->ldap->isResource($entry)) { |
|
1173 | 1173 | continue 2; |
1174 | 1174 | } |
1175 | 1175 | $rr = $entry; //will be expected by nextEntry next round |
1176 | 1176 | $attributes = $this->ldap->getAttributes($cr, $entry); |
1177 | 1177 | $dn = $this->ldap->getDN($cr, $entry); |
1178 | - if($dn === false || in_array($dn, $dnRead)) { |
|
1178 | + if ($dn === false || in_array($dn, $dnRead)) { |
|
1179 | 1179 | continue; |
1180 | 1180 | } |
1181 | 1181 | $newItems = array(); |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | $foundItems = array_merge($foundItems, $newItems); |
1187 | 1187 | $this->resultCache[$dn][$attr] = $newItems; |
1188 | 1188 | $dnRead[] = $dn; |
1189 | - } while(($state === self::LRESULT_PROCESSED_SKIP |
|
1189 | + } while (($state === self::LRESULT_PROCESSED_SKIP |
|
1190 | 1190 | || $this->ldap->isResource($entry)) |
1191 | 1191 | && ($dnReadLimit === 0 || $dnReadCount < $dnReadLimit)); |
1192 | 1192 | } |
@@ -1209,11 +1209,11 @@ discard block |
||
1209 | 1209 | */ |
1210 | 1210 | private function determineFeature($objectclasses, $attr, $dbkey, $confkey, $po = false) { |
1211 | 1211 | $cr = $this->getConnection(); |
1212 | - if(!$cr) { |
|
1212 | + if (!$cr) { |
|
1213 | 1213 | throw new \Exception('Could not connect to LDAP'); |
1214 | 1214 | } |
1215 | 1215 | $p = 'objectclass='; |
1216 | - foreach($objectclasses as $key => $value) { |
|
1216 | + foreach ($objectclasses as $key => $value) { |
|
1217 | 1217 | $objectclasses[$key] = $p.$value; |
1218 | 1218 | } |
1219 | 1219 | $maxEntryObjC = ''; |
@@ -1225,7 +1225,7 @@ discard block |
||
1225 | 1225 | $availableFeatures = |
1226 | 1226 | $this->cumulativeSearchOnAttribute($objectclasses, $attr, |
1227 | 1227 | $dig, $maxEntryObjC); |
1228 | - if(is_array($availableFeatures) |
|
1228 | + if (is_array($availableFeatures) |
|
1229 | 1229 | && count($availableFeatures) > 0) { |
1230 | 1230 | natcasesort($availableFeatures); |
1231 | 1231 | //natcasesort keeps indices, but we must get rid of them for proper |
@@ -1236,7 +1236,7 @@ discard block |
||
1236 | 1236 | } |
1237 | 1237 | |
1238 | 1238 | $setFeatures = $this->configuration->$confkey; |
1239 | - if(is_array($setFeatures) && !empty($setFeatures)) { |
|
1239 | + if (is_array($setFeatures) && !empty($setFeatures)) { |
|
1240 | 1240 | //something is already configured? pre-select it. |
1241 | 1241 | $this->result->addChange($dbkey, $setFeatures); |
1242 | 1242 | } else if ($po && $maxEntryObjC !== '') { |
@@ -1258,7 +1258,7 @@ discard block |
||
1258 | 1258 | * LRESULT_PROCESSED_INVALID or LRESULT_PROCESSED_SKIP |
1259 | 1259 | */ |
1260 | 1260 | private function getAttributeValuesFromEntry($result, $attribute, &$known) { |
1261 | - if(!is_array($result) |
|
1261 | + if (!is_array($result) |
|
1262 | 1262 | || !isset($result['count']) |
1263 | 1263 | || !$result['count'] > 0) { |
1264 | 1264 | return self::LRESULT_PROCESSED_INVALID; |
@@ -1267,12 +1267,12 @@ discard block |
||
1267 | 1267 | // strtolower on all keys for proper comparison |
1268 | 1268 | $result = \OCP\Util::mb_array_change_key_case($result); |
1269 | 1269 | $attribute = strtolower($attribute); |
1270 | - if(isset($result[$attribute])) { |
|
1271 | - foreach($result[$attribute] as $key => $val) { |
|
1272 | - if($key === 'count') { |
|
1270 | + if (isset($result[$attribute])) { |
|
1271 | + foreach ($result[$attribute] as $key => $val) { |
|
1272 | + if ($key === 'count') { |
|
1273 | 1273 | continue; |
1274 | 1274 | } |
1275 | - if(!in_array($val, $known)) { |
|
1275 | + if (!in_array($val, $known)) { |
|
1276 | 1276 | $known[] = $val; |
1277 | 1277 | } |
1278 | 1278 | } |
@@ -1286,7 +1286,7 @@ discard block |
||
1286 | 1286 | * @return bool|mixed |
1287 | 1287 | */ |
1288 | 1288 | private function getConnection() { |
1289 | - if(!is_null($this->cr)) { |
|
1289 | + if (!is_null($this->cr)) { |
|
1290 | 1290 | return $this->cr; |
1291 | 1291 | } |
1292 | 1292 | |
@@ -1298,14 +1298,14 @@ discard block |
||
1298 | 1298 | $this->ldap->setOption($cr, LDAP_OPT_PROTOCOL_VERSION, 3); |
1299 | 1299 | $this->ldap->setOption($cr, LDAP_OPT_REFERRALS, 0); |
1300 | 1300 | $this->ldap->setOption($cr, LDAP_OPT_NETWORK_TIMEOUT, self::LDAP_NW_TIMEOUT); |
1301 | - if($this->configuration->ldapTLS === 1) { |
|
1301 | + if ($this->configuration->ldapTLS === 1) { |
|
1302 | 1302 | $this->ldap->startTls($cr); |
1303 | 1303 | } |
1304 | 1304 | |
1305 | 1305 | $lo = @$this->ldap->bind($cr, |
1306 | 1306 | $this->configuration->ldapAgentName, |
1307 | 1307 | $this->configuration->ldapAgentPassword); |
1308 | - if($lo === true) { |
|
1308 | + if ($lo === true) { |
|
1309 | 1309 | $this->$cr = $cr; |
1310 | 1310 | return $cr; |
1311 | 1311 | } |
@@ -1340,14 +1340,14 @@ discard block |
||
1340 | 1340 | $portSettings = array(); |
1341 | 1341 | |
1342 | 1342 | //In case the port is already provided, we will check this first |
1343 | - if($port > 0) { |
|
1343 | + if ($port > 0) { |
|
1344 | 1344 | $hostInfo = parse_url($host); |
1345 | - if(!(is_array($hostInfo) |
|
1345 | + if (!(is_array($hostInfo) |
|
1346 | 1346 | && isset($hostInfo['scheme']) |
1347 | 1347 | && stripos($hostInfo['scheme'], 'ldaps') !== false)) { |
1348 | 1348 | $portSettings[] = array('port' => $port, 'tls' => true); |
1349 | 1349 | } |
1350 | - $portSettings[] =array('port' => $port, 'tls' => false); |
|
1350 | + $portSettings[] = array('port' => $port, 'tls' => false); |
|
1351 | 1351 | } |
1352 | 1352 | |
1353 | 1353 | //default ports |