├── .github └── workflows │ ├── moodle-plugin-ci.yml │ └── moodle-release.yml ├── CHANGES.md ├── COPYING.txt ├── README.md ├── UPGRADE.md ├── auth.php ├── classes ├── eventobservers.php ├── privacy │ └── provider.php └── task │ ├── asynchronous_sync_task.php │ ├── sync_roles.php │ └── sync_task.php ├── cli └── sync_users.php ├── db ├── events.php ├── tasks.php └── upgrade.php ├── lang └── en │ └── auth_ldap_syncplus.php ├── locallib.php ├── settings.php ├── tests ├── behat │ ├── auth_ldap_syncplus.feature │ └── behat_auth_ldap_syncplus.php └── fixtures │ ├── bitnami-openldap-docker-compose.yaml │ └── ldifs │ └── auth_ldap_syncplus.ldif └── version.php /.github/workflows/moodle-plugin-ci.yml: -------------------------------------------------------------------------------- 1 | name: Moodle Plugin CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | test: 7 | runs-on: ubuntu-22.04 8 | 9 | services: 10 | postgres: 11 | image: postgres:14 12 | env: 13 | POSTGRES_USER: 'postgres' 14 | POSTGRES_HOST_AUTH_METHOD: 'trust' 15 | ports: 16 | - 5432:5432 17 | options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 18 | 19 | mariadb: 20 | image: mariadb:10 21 | env: 22 | MYSQL_USER: 'root' 23 | MYSQL_ALLOW_EMPTY_PASSWORD: "true" 24 | MYSQL_CHARACTER_SET_SERVER: "utf8mb4" 25 | MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci" 26 | ports: 27 | - 3306:3306 28 | options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3 29 | 30 | strategy: 31 | fail-fast: false 32 | matrix: 33 | php: ['8.2', '8.3', '8.4'] 34 | moodle-branch: ['MOODLE_500_STABLE'] 35 | database: [pgsql, mariadb] 36 | 37 | steps: 38 | - name: Check out the plugin repository (but just to start the Bitnami docker container from the fixtures subdirectory) 39 | uses: actions/checkout@v4 40 | with: 41 | repository: moodle-an-hochschulen/moodle-auth_ldap_syncplus 42 | # Ideally, we would checkout ${{ matrix.moodle-branch }} here. 43 | # But when doing a plugin upgrade, this would let the build fail. 44 | # Thus we checkout always the main branch and hope that the steps to start up the Bitnami container won't change too often. 45 | ref: main 46 | path: bitnami-container 47 | 48 | - name: Start Bitnami LDAP 49 | uses: adambirds/docker-compose-action@v1.4.0 50 | with: 51 | compose-file: ${{ github.workspace }}/bitnami-container/tests/fixtures/bitnami-openldap-docker-compose.yaml 52 | 53 | - name: Check out repository code 54 | uses: actions/checkout@v4 55 | with: 56 | path: plugin 57 | 58 | - name: Setup PHP ${{ matrix.php }} 59 | uses: shivammathur/setup-php@v2 60 | with: 61 | php-version: ${{ matrix.php }} 62 | extensions: ${{ matrix.extensions }} 63 | ini-values: max_input_vars=5000 64 | coverage: none 65 | 66 | - name: Initialise moodle-plugin-ci 67 | run: | 68 | composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4 69 | echo $(cd ci/bin; pwd) >> $GITHUB_PATH 70 | echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH 71 | sudo locale-gen en_AU.UTF-8 72 | echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV 73 | 74 | - name: Install moodle-plugin-ci 75 | run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 76 | env: 77 | DB: ${{ matrix.database }} 78 | MOODLE_BRANCH: ${{ matrix.moodle-branch }} 79 | 80 | - name: PHP Lint 81 | if: ${{ !cancelled() }} 82 | run: moodle-plugin-ci phplint 83 | 84 | - name: PHP Mess Detector 85 | continue-on-error: true # This step will show errors but will not fail 86 | if: ${{ !cancelled() }} 87 | run: moodle-plugin-ci phpmd 88 | 89 | - name: Moodle Code Checker 90 | if: ${{ !cancelled() }} 91 | run: moodle-plugin-ci phpcs --max-warnings 0 92 | 93 | - name: Moodle PHPDoc Checker 94 | if: ${{ !cancelled() }} 95 | run: moodle-plugin-ci phpdoc --max-warnings 0 96 | 97 | - name: Validating 98 | if: ${{ !cancelled() }} 99 | run: moodle-plugin-ci validate 100 | 101 | - name: Check upgrade savepoints 102 | if: ${{ !cancelled() }} 103 | run: moodle-plugin-ci savepoints 104 | 105 | - name: Mustache Lint 106 | if: ${{ !cancelled() }} 107 | run: moodle-plugin-ci mustache 108 | 109 | - name: Grunt 110 | if: ${{ !cancelled() }} 111 | run: moodle-plugin-ci grunt --max-lint-warnings 0 112 | 113 | - name: PHPUnit tests 114 | if: ${{ !cancelled() }} 115 | run: moodle-plugin-ci phpunit --fail-on-warning 116 | 117 | - name: Behat features 118 | id: behat 119 | if: ${{ !cancelled() }} 120 | run: moodle-plugin-ci behat --profile chrome 121 | 122 | - name: Upload Behat Faildump 123 | if: ${{ failure() && steps.behat.outcome == 'failure' }} 124 | uses: actions/upload-artifact@v4 125 | with: 126 | name: Behat Faildump (${{ join(matrix.*, ', ') }}) 127 | path: ${{ github.workspace }}/moodledata/behat_dump 128 | retention-days: 7 129 | if-no-files-found: ignore 130 | 131 | - name: Mark cancelled jobs as failed. 132 | if: ${{ cancelled() }} 133 | run: exit 1 134 | -------------------------------------------------------------------------------- /.github/workflows/moodle-release.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Whenever a new tag starting with "v" is pushed, add the tagged version 3 | # to the Moodle Plugins directory at https://moodle.org/plugins 4 | # 5 | # revision: 2021070201 6 | # 7 | name: Releasing in the Plugins directory 8 | 9 | on: 10 | push: 11 | tags: 12 | - v* 13 | 14 | workflow_dispatch: 15 | inputs: 16 | tag: 17 | description: 'Tag to be released' 18 | required: true 19 | 20 | defaults: 21 | run: 22 | shell: bash 23 | 24 | jobs: 25 | release-at-moodle-org: 26 | runs-on: ubuntu-latest 27 | env: 28 | PLUGIN: auth_ldap_syncplus 29 | CURL: curl -s 30 | ENDPOINT: https://moodle.org/webservice/rest/server.php 31 | TOKEN: ${{ secrets.MOODLE_ORG_TOKEN }} 32 | FUNCTION: local_plugins_add_version 33 | 34 | steps: 35 | - name: Call the service function 36 | id: add-version 37 | run: | 38 | if [[ ! -z "${{ github.event.inputs.tag }}" ]]; then 39 | TAGNAME="${{ github.event.inputs.tag }}" 40 | elif [[ $GITHUB_REF = refs/tags/* ]]; then 41 | TAGNAME="${GITHUB_REF##*/}" 42 | fi 43 | if [[ -z "${TAGNAME}" ]]; then 44 | echo "No tag name has been provided!" 45 | exit 1 46 | fi 47 | ZIPURL="https://api.github.com/repos/${{ github.repository }}/zipball/${TAGNAME}" 48 | RESPONSE=$(${CURL} ${ENDPOINT} --data-urlencode "wstoken=${TOKEN}" \ 49 | --data-urlencode "wsfunction=${FUNCTION}" \ 50 | --data-urlencode "moodlewsrestformat=json" \ 51 | --data-urlencode "frankenstyle=${PLUGIN}" \ 52 | --data-urlencode "zipurl=${ZIPURL}" \ 53 | --data-urlencode "vcssystem=git" \ 54 | --data-urlencode "vcsrepositoryurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" \ 55 | --data-urlencode "vcstag=${TAGNAME}" \ 56 | --data-urlencode "changelogurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commits/${TAGNAME}" \ 57 | --data-urlencode "altdownloadurl=${ZIPURL}") 58 | echo "response=${RESPONSE}" >> $GITHUB_OUTPUT 59 | 60 | - name: Evaluate the response 61 | id: evaluate-response 62 | env: 63 | RESPONSE: ${{ steps.add-version.outputs.response }} 64 | run: | 65 | jq <<< ${RESPONSE} 66 | jq --exit-status ".id" <<< ${RESPONSE} > /dev/null 67 | -------------------------------------------------------------------------------- /CHANGES.md: -------------------------------------------------------------------------------- 1 | moodle-auth_ldap_syncplus 2 | ========================= 3 | 4 | Changes 5 | ------- 6 | 7 | ### v5.0-r1 8 | 9 | * 2025-04-14 - Prepare compatibility for Moodle 5.0. 10 | 11 | ### v4.5-r3 12 | 13 | * 2025-03-31 - Deprecation: core\session\manager::kill_user_sessions has been deprecated since 4.5, resolves #41. 14 | * 2025-02-17 - Bugfix: The sync task did not close the DB transaction if an invaliduserexception was thrown, adopt changes from auth_ldap in MDL-79362. 15 | 16 | ### v4.5-r2 17 | 18 | * 2024-11-12 - Upgrade: Adopt changes from MDL-73703 and break the sync task user updates into chunks, resolves #36 19 | * 2024-11-12 - Upgrade: Adopt changes from MDL-66151 and use \core\session\manager::destroy_user_sessions() now. 20 | * 2024-11-12 - Improvement: Change location of event observer code, resolves #26 21 | 22 | ### v4.5-r1 23 | 24 | * 2024-10-14 - Upgrade: Adopt changes from MDL-81960 and use new \core\url class 25 | * 2024-10-14 - Upgrade: Adopt changes from MDL-81920 and use new \core\lang_string class. 26 | * 2024-10-07 - Prepare compatibility for Moodle 4.5. 27 | 28 | ### v4.4-r1 29 | 30 | * 2024-08-24 - Development: Rename master branch to main, please update your clones. 31 | * 2024-08-22 - Upgrade: Fix Behat scenarios which broke on 4.4. 32 | * 2024-08-20 - Prepare compatibility for Moodle 4.4. 33 | 34 | ### v4.3-r2 35 | 36 | * 2024-08-19 - Fix behat tests which broke due to Github actions changes 37 | * 2024-08-11 - Add section for scheduled tasks to README 38 | * 2024-08-11 - Updated Moodle Plugin CI to latest upstream recommendations 39 | 40 | ### v4.3-r1 41 | 42 | * 2023-10-20 - Prepare compatibility for Moodle 4.3. 43 | 44 | ### v4.2-r1 45 | 46 | * 2023-09-01 - Prepare compatibility for Moodle 4.2. 47 | 48 | ### v4.1-r2 49 | 50 | * 2023-10-14 - Add automated release to moodle.org/plugins 51 | * 2023-10-14 - Make codechecker happy again 52 | * 2023-10-10 - Updated Moodle Plugin CI to latest upstream recommendations 53 | * 2023-04-30 - Tests: Updated Moodle Plugin CI to use PHP 8.1 and Postgres 13 from Moodle 4.1 on. 54 | 55 | ### v4.1-r1 56 | 57 | * 2023-01-21 - Prepare compatibility for Moodle 4.1. 58 | * 2023-03-12 - Tests: Fix a Behat test which broke after Moodle core upstream changes 59 | * 2023-03-11 - Make codechecker happy again 60 | * 2023-03-11 - Tests: Change the branch which is checked out to start ldap 61 | * 2022-12-27 - Add some automated tests on Github actions, solves #32 62 | * 2022-11-28 - Updated Moodle Plugin CI to latest upstream recommendations 63 | 64 | ### v4.0-r1 65 | 66 | * 2022-11-23 - Revert backport of MDL-58395. 67 | * 2022-07-12 - Prepare compatibility for Moodle 4.0. 68 | 69 | ### v3.11-r4 70 | 71 | * 2022-11-06 - Backport MDL-58395 from auth_ldap to version 3.11 of this plugin. 72 | * 2022-11-06 - Adopt code change of MDL-60666 from auth_ldap. 73 | * 2022-11-05 - Remove support for PHP < 7.3 (i.e. adopt code change of MDL-73500 from auth_ldap) 74 | * 2022-11-05 - Adopt code change of MDL-69492 from auth_ldap. 75 | 76 | ### v3.11-r3 77 | 78 | * 2022-07-10 - Add Visual checks section to UPGRADE.md 79 | * 2022-07-10 - Add Capabilities section to README.md 80 | 81 | ### v3.11-r2 82 | 83 | * 2022-06-26 - Make codechecker happy again 84 | * 2022-06-26 - Updated Moodle Plugin CI to latest upstream recommendations 85 | * 2022-06-26 - Add UPGRADE.md as internal upgrade documentation 86 | * 2022-06-26 - Update maintainers and copyrights in README.md. 87 | 88 | ### v3.11-r1 89 | 90 | * 2021-07-20 - Prepare compatibility for Moodle 3.11. 91 | * 2021-02-05 - Move Moodle Plugin CI from Travis CI to Github actions 92 | 93 | ### v3.10-r1 94 | 95 | * 2020-12-11 - Adopt code changes from Moodle 3.10 core auth_ldap. 96 | * 2020-12-11 - Prepare compatibility for Moodle 3.10. 97 | * 2020-12-10 - Change in Moodle release support: 98 | For the time being, this plugin is maintained for the most recent LTS release of Moodle as well as the most recent major release of Moodle. 99 | Bugfixes are backported to the LTS release. However, new features and improvements are not necessarily backported to the LTS release. 100 | * 2020-12-10 - Improvement: Declare which major stable version of Moodle this plugin supports (see MDL-59562 for details). 101 | 102 | ### v3.9-r1 103 | 104 | * 2020-09-18 - Prepare compatibility for Moodle 3.9. 105 | * 2020-02-26 - Added Behat tests. 106 | 107 | ### v3.8-r1 108 | 109 | * 2020-02-19 - Adopt code changes Moodle 3.8 core auth_ldap. 110 | * 2020-02-19 - Prepare compatibility for Moodle 3.8. 111 | 112 | ### v3.7-r1 113 | 114 | * 2019-08-15 - Make codechecker happy. 115 | * 2019-08-15 - Prepare compatibility for Moodle 3.7. 116 | 117 | ### v3.6-r1 118 | 119 | * 2019-01-29 - Check compatibility for Moodle 3.6, no functionality change. 120 | 121 | ### v3.5-r2 122 | 123 | * 2019-01-29 - Adopt code changes Moodle 3.5 core auth_ldap (MDL-63887). 124 | * 2018-12-05 - Changed travis.yml due to upstream changes. 125 | 126 | ### v3.5-r1 127 | 128 | * 2018-06-25 - Bugfix: Creating users and first logins resulted in a fatal error in 3.5 because of a visibility change of update_user_record() in Moodle core. 129 | * 2018-06-25 - Check compatibility for Moodle 3.5, no functionality change. 130 | 131 | ### v3.4-r4 132 | 133 | * 2018-05-16 - Implement Privacy API. 134 | 135 | ### v3.4-r3 136 | 137 | * 2018-02-07 - Bugfix: Login via email for first-time LDAP logins did not work if multiple LDAP contexts were configured; Credits to derhelge. 138 | 139 | ### v3.4-r2 140 | 141 | * 2018-02-07 - Add forgotten sync_roles task definition 142 | 143 | ### v3.4-r1 144 | 145 | * 2018-02-07 - Adopt code changes in Moodle 3.4 core auth_ldap: Assign arbitrary system roles via LDAP sync. 146 | * 2018-02-06 - Check compatibility for Moodle 3.4, no functionality change. 147 | 148 | ### v3.3-r1 149 | 150 | * 2018-02-02 - Adopt code changes in Moodle 3.3 core auth_ldap: Sync user profile fields 151 | * 2018-02-02 - Adopt code changes in Moodle 3.3 core auth_ldap: Convert auth plugins to use settings.php. Please double-check your plugin settings after upgrading to this version. 152 | * 2017-12-12 - Prepare compatibility for Moodle 3.3, no functionality change. 153 | * 2017-12-05 - Added Workaround to travis.yml for fixing Behat tests with TravisCI. 154 | * 2017-11-08 - Updated travis.yml to use newer node version for fixing TravisCI error. 155 | 156 | ### v3.2-r4 157 | 158 | * 2017-05-29 - Add Travis CI support 159 | 160 | ### v3.2-r3 161 | 162 | * 2017-05-05 - Improve README.md 163 | 164 | ### v3.2-r2 165 | 166 | * 2017-03-03 - Adopt code changes in Moodle 3.2 core auth_ldap 167 | 168 | ### v3.2-r1 169 | 170 | * 2017-01-13 - Check compatibility for Moodle 3.2, no functionality change 171 | * 2017-01-13 - Adopt code changes in Moodle 3.2 core auth_ldap 172 | * 2017-01-12 - Move Changelog from README.md to CHANGES.md 173 | 174 | ### v3.1-r1 175 | 176 | * 2016-07-19 - Adopt code changes in Moodle core auth_ldap, adding the possibility to sync the "suspended" attribute 177 | * 2016-07-19 - Check compatibility for Moodle 3.1, no functionality change 178 | 179 | ### Changes before v3.1 180 | 181 | * 2016-03-20 - Edit README to reflect the current naming of the User account syncronisation setting, no functionality change 182 | * 2016-02-10 - Change plugin version and release scheme to the scheme promoted by moodle.org, no functionality change 183 | * 2016-01-01 - Adopt code changes in Moodle core auth_ldap, including the new scheduled task feature. If you have used a LDAP syncronization cron job before, please use the LDAP syncronisation scheduled task from now on (for details, see "Configuring LDAP synchronization task" section below) 184 | * 2016-01-01 - Check compatibility for Moodle 3.0, no functionality change 185 | * 2015-08-18 - Check compatibility for Moodle 2.9, no functionality change 186 | * 2015-08-18 - Adopt a code change in Moodle core auth_ldap 187 | * 2015-01-29 - Check compatibility for Moodle 2.8, no functionality change 188 | * 2015-01-23 - Adopt a code change in Moodle core auth_ldap 189 | * 2014-10-08 - Adopt a code change in Moodle core auth_ldap 190 | * 2014-09-12 - Bugfix: Fetching user details from LDAP on manual user creation didn't work in some circumstances 191 | * 2014-09-02 - Bugfix: Check if LDAP auth is really used on manual user creation 192 | * 2014-08-29 - Support login via email for first-time LDAP logins (MDL-46638) 193 | * 2014-08-29 - Update version.php 194 | * 2014-08-29 - Update README file 195 | * 2014-08-27 - Change line breaks to mtrace() (MDL-30589) 196 | * 2014-08-25 - Support new event API, remove legacy event handling 197 | * 2014-07-31 - Add event handler for "user_created" event (see "Fetching user details from LDAP on manual user creation" below for details - MDL-47029) 198 | * 2014-06-30 - Check compatibility for Moodle 2.7, no functionality change 199 | * 2014-03-12 - Initial version 200 | -------------------------------------------------------------------------------- /COPYING.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | moodle-auth_ldap_syncplus 2 | ========================= 3 | 4 | [![Moodle Plugin CI](https://github.com/moodle-an-hochschulen/moodle-auth_ldap_syncplus/actions/workflows/moodle-plugin-ci.yml/badge.svg?branch=main)](https://github.com/moodle-an-hochschulen/moodle-auth_ldap_syncplus/actions?query=workflow%3A%22Moodle+Plugin+CI%22+branch%3Amain) 5 | 6 | Moodle authentication plugin which provides all functionality of auth_ldap, but supports advanced features for the LDAP synchronization task and LDAP authentication. 7 | 8 | 9 | Requirements 10 | ------------ 11 | 12 | This plugin requires Moodle 5.0+ 13 | 14 | 15 | Motivation for this plugin 16 | -------------------------- 17 | 18 | Moodle core's auth_ldap authentication plugin is a great basis for authenticating users in Moodle. However, as Moodle core's auth_ldap is somehow limited in several aspects and there is no prospect to have it improved in Moodle core, we have implemented an extended version for LDAP authentication with these key features: 19 | 20 | * The most important part: All functions from auth_ldap are still working if you use this authentication plugin. 21 | 22 | * The plugin adds the possibility to the LDAP synchronization task to suspend users which have disappeared in LDAP for a configurable amount of days and delete them only after this grace period (the Moodle core LDAP synchronization task only provides you the option to suspend _or_ delete users which have disappeared in LDAP - MDL-47018). 23 | 24 | * You can prevent the LDAP synchronization task from creating Moodle accounts for all LDAP users if they have never logged into Moodle before (the Moodle core LDAP synchronization task always creates Moodle accounts for all LDAP users - MDL-29249). 25 | 26 | * You can fetch user details from LDAP on manual user creation (MDL-47029). 27 | 28 | * It supports login via email for first-time LDAP logins (Moodle core only supports login via email for existing Moodle users - MDL-46638) 29 | 30 | * It adds several line breaks to the output of the LDAP synchronization task to improve readability (MDL-30589). 31 | 32 | 33 | Installation 34 | ------------ 35 | 36 | Install the plugin like any other plugin to folder 37 | /auth/ldap_syncplus 38 | 39 | See http://docs.moodle.org/en/Installing_plugins for details on installing Moodle plugins 40 | 41 | 42 | Usage & Settings 43 | ---------------- 44 | 45 | After installing the plugin, it does not do anything to Moodle yet. 46 | 47 | To configure the plugin and its behaviour, please visit: 48 | Site administration -> Plugins -> Authentication -> Manage authentication -> LDAP server (Sync Plus) 49 | 50 | There, you configure the plugin with the same settings like you would configure the Moodle core LDAP authentication method. 51 | 52 | Please note that there are additional setting items in settings section "User account synchronisation" compared to the Moodle core LDAP authentication method: 53 | 54 | ### 1. Removed ext user 55 | 56 | The setting "Removed ext user" has an additional option called "Suspend internal and fully delete internal after grace period". If you select this option, the synchronization task will suspend users which have disappeared in LDAP for a configurable amount of days and delete them only after this grace period. If the user reappears in LDAP within the grace period, his Moodle account is revived and he can login again into Moodle as he did before. 57 | 58 | ### 2. Fully deleting grace period 59 | 60 | With the setting "Fully deleting grace period" (Default: 10 days), you can control the length of the grace period until a user account is fully deleted after it has disappeared from LDAP. 61 | 62 | ### 3. Add new users 63 | 64 | With the setting "Add new users" (Default: yes), you can prevent the synchronization task from creating Moodle accounts for all LDAP users if they have never logged into Moodle before. 65 | 66 | After configuring the LDAP server (Sync Plus) authentication method, you have to activate the plugin on Site administration -> Plugins -> Authentication -> Manage authentication so that users can be authenticated with this authentication method. Afterwards, you can deactivate the Moodle core LDAP authentication method as it is not needed anymore actively. 67 | 68 | 69 | Configuring LDAP User account synchronisation 70 | --------------------------------------------- 71 | 72 | To leverage the additional LDAP synchronization features of auth_ldap_syncplus, you have to disable the scheduled task of the Moodle core auth_ldap plugin and activate and configure the scheduled task of auth_ldap_syncplus. This is done on Site administration -> Server -> Scheduled tasks. 73 | 74 | If you don't know how to setup LDAP User account synchronisation at all, see https://docs.moodle.org/en/LDAP_authentication#Enabling_the_LDAP_users_sync_job. 75 | 76 | 77 | Configuring LDAP User role synchronisation 78 | ------------------------------------------ 79 | 80 | In addition to the LDAP user account synchronisation, there is a LDAP user role synchronisation. LDAP user role synchronisation task in auth_ldap_syncplus does not provide any benefits over the LDAP user role synchronisation in Moodle core auth_ldap yet. However, to keep things in one place and if you want to synchronize LDAP user roles, you should activate and configure the scheduled task of auth_ldap_syncplus instead of auth_ldap. This is done on Site administration -> Server -> Scheduled tasks. 81 | 82 | If you don't know about the LDAP user role synchronisation at all, see https://docs.moodle.org/en/LDAP_authentication#Assign_system_roles. 83 | 84 | 85 | Migrating from auth_ldap to auth_ldap_syncplus 86 | ---------------------------------------------- 87 | 88 | If you already have users in your Moodle installation who authenticate using the auth_ldap authentication method and want to switch them to auth_ldap_syncplus, proceed this way: 89 | 90 | * Configure auth_ldap_syncplus as an _additional_ authentication method while keeping auth_ldap activated. 91 | 92 | * Create a test user and set his authentication method to auth_ldap_syncplus. Test if this user is able to log into Moodle properly. 93 | 94 | * Switch all existing users to the auth_ldap_syncplus authentication method by running the following SQL command in your Moodle database: 95 | `UPDATE mdl_user SET auth='ldap_syncplus' WHERE auth='ldap'` 96 | 97 | * Disable auth_ldap authentication method. 98 | 99 | 100 | Fetching user details from LDAP on manual user creation 101 | ------------------------------------------------------- 102 | 103 | Normally, when a new user logs into Moodle for the first time and a Moodle account is automatically created, Moodle pulls the user's details from LDAP and stores them in the Moodle user profile according to the LDAP plugin's settings. 104 | 105 | auth_ldap_syncplus extends this behaviour of pulling user details from LDAP: 106 | With auth_ldap_syncplus, you can create an user manually on Site administration -> Users -> Accounts -> Add a new user. The only thing you have to specify correctly is the username (which corresponds to the username in LDAP). All other details like first name or email address can be filled with placeholder content. After you click the "Create user" button, Moodle pulls the other user's details from LDAP and creates the user account correctly with the details from LDAP. 107 | 108 | This feature is enabled automatically and can be used as soon as you are using auth_ldap_syncplus as your LDAP authentication plugin like described above. 109 | 110 | 111 | Capabilities 112 | ------------ 113 | 114 | This plugin does not add any additional capabilities. 115 | 116 | 117 | Scheduled Tasks 118 | --------------- 119 | 120 | This plugin also introduces these additional scheduled tasks: 121 | 122 | ### \auth_ldap_syncplus\task\sync_roles 123 | 124 | This task is basically the same as the \auth_ldap\task\sync_roles task and will sync roles from LDAP.\ 125 | By default, the task is disabled. 126 | 127 | ### \auth_ldap_syncplus\task\sync_task 128 | 129 | This task is basically the same as the \auth_ldap\task\sync_task task and will sync users from LDAP.\ 130 | By default, the task is disabled. 131 | 132 | 133 | How this plugin works 134 | --------------------- 135 | 136 | This plugin is implemented with minimal code duplication in mind. It inherits / requires as much code as possible from auth_ldap and only implements the extended functionalities. 137 | 138 | 139 | Theme support 140 | ------------- 141 | 142 | This plugin acts behind the scenes, therefore it should work with all Moodle themes. 143 | This plugin is developed and tested on Moodle Core's Boost theme. 144 | It should also work with Boost child themes, including Moodle Core's Classic theme. However, we can't support any other theme than Boost. 145 | 146 | 147 | Plugin repositories 148 | ------------------- 149 | 150 | This plugin is published and regularly updated in the Moodle plugins repository: 151 | http://moodle.org/plugins/view/auth_ldap_syncplus 152 | 153 | The latest development version can be found on Github: 154 | https://github.com/moodle-an-hochschulen/moodle-auth_ldap_syncplus 155 | 156 | 157 | Bug and problem reports / Support requests 158 | ------------------------------------------ 159 | 160 | This plugin is carefully developed and thoroughly tested, but bugs and problems can always appear. 161 | 162 | Please report bugs and problems on Github: 163 | https://github.com/moodle-an-hochschulen/moodle-auth_ldap_syncplus/issues 164 | 165 | We will do our best to solve your problems, but please note that due to limited resources we can't always provide per-case support. 166 | 167 | 168 | Feature proposals 169 | ----------------- 170 | 171 | Due to limited resources, the functionality of this plugin is primarily implemented for our own local needs and published as-is to the community. We are aware that members of the community will have other needs and would love to see them solved by this plugin. 172 | 173 | Please issue feature proposals on Github: 174 | https://github.com/moodle-an-hochschulen/moodle-auth_ldap_syncplus/issues 175 | 176 | Please create pull requests on Github: 177 | https://github.com/moodle-an-hochschulen/moodle-auth_ldap_syncplus/pulls 178 | 179 | We are always interested to read about your feature proposals or even get a pull request from you, but please accept that we can handle your issues only as feature _proposals_ and not as feature _requests_. 180 | 181 | 182 | Moodle release support 183 | ---------------------- 184 | 185 | Due to limited resources, this plugin is only maintained for the most recent major release of Moodle as well as the most recent LTS release of Moodle. Bugfixes are backported to the LTS release. However, new features and improvements are not necessarily backported to the LTS release. 186 | 187 | Apart from these maintained releases, previous versions of this plugin which work in legacy major releases of Moodle are still available as-is without any further updates in the Moodle Plugins repository. 188 | 189 | There may be several weeks after a new major release of Moodle has been published until we can do a compatibility check and fix problems if necessary. If you encounter problems with a new major release of Moodle - or can confirm that this plugin still works with a new major release - please let us know on Github. 190 | 191 | If you are running a legacy version of Moodle, but want or need to run the latest version of this plugin, you can get the latest version of the plugin, remove the line starting with $plugin->requires from version.php and use this latest plugin version then on your legacy Moodle. However, please note that you will run this setup completely at your own risk. We can't support this approach in any way and there is an undeniable risk for erratic behavior. 192 | 193 | 194 | Translating this plugin 195 | ----------------------- 196 | 197 | This Moodle plugin is shipped with an english language pack only. All translations into other languages must be managed through AMOS (https://lang.moodle.org) by what they will become part of Moodle's official language pack. 198 | 199 | As the plugin creator, we manage the translation into german for our own local needs on AMOS. Please contribute your translation into all other languages in AMOS where they will be reviewed by the official language pack maintainers for Moodle. 200 | 201 | 202 | Right-to-left support 203 | --------------------- 204 | 205 | This plugin has not been tested with Moodle's support for right-to-left (RTL) languages. 206 | If you want to use this plugin with a RTL language and it doesn't work as-is, you are free to send us a pull request on Github with modifications. 207 | 208 | 209 | Contribution to Moodle Core 210 | --------------------------- 211 | 212 | There is a Moodle tracker ticket on https://tracker.moodle.org/browse/MDL-47030 which proposes to add the improved features of this plugin to Moodle core auth_ldap plugin. 213 | 214 | Please vote for this ticket if you want to have this realized. 215 | 216 | 217 | Maintainers 218 | ----------- 219 | 220 | The plugin is maintained by\ 221 | Moodle an Hochschulen e.V. 222 | 223 | 224 | Copyright 225 | --------- 226 | 227 | The copyright of this plugin is held by\ 228 | Moodle an Hochschulen e.V. 229 | 230 | Individual copyrights of individual developers are tracked in PHPDoc comments and Git commits. 231 | 232 | 233 | Initial copyright 234 | ----------------- 235 | 236 | This plugin was initially built, maintained and published by\ 237 | Ulm University\ 238 | Communication and Information Centre (kiz)\ 239 | Alexander Bias 240 | 241 | It was contributed to the Moodle an Hochschulen e.V. plugin catalogue in 2022. 242 | -------------------------------------------------------------------------------- /UPGRADE.md: -------------------------------------------------------------------------------- 1 | Upgrading this plugin 2 | ===================== 3 | 4 | This is an internal documentation for plugin developers with some notes what has to be considered when updating this plugin to a new Moodle major version. 5 | 6 | General 7 | ------- 8 | 9 | * Generally, this is a quite simple plugin with just one purpose. 10 | * It does not rely on any fluctuating library functions and should remain quite stable between Moodle major versions. 11 | * However, as it deals with the communication to a backend system, things are slightly more complicated. 12 | * Thus, the upgrading effort is medium. 13 | 14 | 15 | Upstream changes 16 | ---------------- 17 | 18 | * This plugin is built on top of auth_ldap from Moodle core. It inherits the codebase from auth_ldap and overwrites and extends some functions. Doing this, code duplication couldn't be avoided. If there are any upstream changes in auth_ldap, you should check if they should be adopted to this plugin as well. 19 | 20 | 21 | Automated tests 22 | --------------- 23 | 24 | * The plugin has a good coverage with Behat tests which test all of the plugin's user stories. 25 | * To run the automated tests, a running LDAP server is necessary. This is realized in the Github actions workflow. If you want to run the automated tests locally, you have to adapt the tests to a local LDAP server yourself. 26 | If you do not have a running LDAP server at hand, you can try to spin up the Bitnami LDAP server which is used in Github actions with this docker-compose command: 27 | ``` 28 | docker-compose -p ldap -f auth/ldap_syncplus/tests/fixtures/bitnami-openldap-docker-compose.yaml up 29 | ``` 30 | 31 | 32 | Manual tests 33 | ------------ 34 | 35 | * Even though there are automated tests, as the plugin deals with the communication to a backend system, manual tests should be carried out to see if the plugin's functionality really works with a real LDAP server. 36 | 37 | 38 | Visual checks 39 | ------------- 40 | 41 | * There aren't any additional visual checks in the Moodle GUI needed to upgrade this plugin. 42 | -------------------------------------------------------------------------------- /auth.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Auth plugin "LDAP SyncPlus" 19 | * 20 | * @package auth_ldap_syncplus 21 | * @copyright 2014 Alexander Bias, Ulm University 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | 25 | defined('MOODLE_INTERNAL') || die; 26 | 27 | // phpcs:disable 28 | // Let codechecker ignore this file. This code mostly re-used from auth_ldap and the problems are already there and not made by us. 29 | 30 | global $CFG; 31 | 32 | require_once($CFG->libdir.'/authlib.php'); 33 | require_once($CFG->libdir.'/ldaplib.php'); 34 | require_once($CFG->dirroot.'/user/lib.php'); 35 | require_once($CFG->dirroot.'/auth/ldap/locallib.php'); 36 | require_once(__DIR__.'/../ldap/auth.php'); 37 | require_once(__DIR__.'/locallib.php'); 38 | 39 | /** 40 | * Auth plugin "LDAP SyncPlus" - Auth class 41 | * 42 | * @package auth_ldap_syncplus 43 | * @copyright 2014 Alexander Bias, Ulm University 44 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 45 | */ 46 | class auth_plugin_ldap_syncplus extends auth_plugin_ldap { 47 | 48 | /** 49 | * Constructor with initialisation. 50 | */ 51 | public function __construct() { 52 | $this->authtype = 'ldap_syncplus'; 53 | $this->roleauth = 'auth_ldap'; 54 | $this->errorlogtag = '[AUTH LDAP SYNCPLUS] '; 55 | $this->init_plugin($this->authtype); 56 | } 57 | 58 | /** 59 | * Old syntax of class constructor. Deprecated in PHP7. 60 | * 61 | * @deprecated since Moodle 3.1 62 | */ 63 | public function auth_plugin_ldap_syncplus() { 64 | debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); 65 | self::__construct(); 66 | } 67 | 68 | 69 | /** 70 | * Synchronise users from the external LDAP server to Moodle's user table. 71 | * 72 | * Calls sync_users_update_callback() with default callback if appropriate. 73 | * 74 | * @param bool $doupdates will do pull in data updates from LDAP if relevant 75 | * @return bool success 76 | */ 77 | public function sync_users($doupdates = true) { 78 | return $this->sync_users_update_callback($doupdates ? [$this, 'update_users'] : null); 79 | } 80 | 81 | /** 82 | * Synchronise users from the external LDAP server to Moodle's user table (callback). 83 | * 84 | * Sync is now using username attribute. 85 | * 86 | * Syncing users removes or suspends users that dont exists anymore in external LDAP. 87 | * Creates new users and updates coursecreator status of users. 88 | * 89 | * @param callable|null $updatecallback will do pull in data updates from LDAP if relevant 90 | * @return bool success 91 | */ 92 | public function sync_users_update_callback(?callable $updatecallback = null): bool { 93 | global $CFG, $DB; 94 | 95 | require_once($CFG->dirroot . '/user/profile/lib.php'); 96 | 97 | mtrace(get_string('connectingldap', 'auth_ldap')); 98 | $ldapconnection = $this->ldap_connect(); 99 | 100 | $dbman = $DB->get_manager(); 101 | 102 | // Define table user to be created. 103 | $table = new xmldb_table('tmp_extuser'); 104 | $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); 105 | $table->add_field('username', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null); 106 | $table->add_field('mnethostid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); 107 | $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); 108 | $table->add_index('username', XMLDB_INDEX_UNIQUE, array('mnethostid', 'username')); 109 | 110 | mtrace(get_string('creatingtemptable', 'auth_ldap', 'tmp_extuser')); 111 | $dbman->create_temp_table($table); 112 | 113 | // Get user's list from ldap to sql in a scalable fashion. 114 | // Prepare some data we'll need. 115 | $filter = '(&('.$this->config->user_attribute.'=*)'.$this->config->objectclass.')'; 116 | $servercontrols = array(); 117 | 118 | $contexts = explode(';', $this->config->contexts); 119 | 120 | if (!empty($this->config->create_context)) { 121 | array_push($contexts, $this->config->create_context); 122 | } 123 | 124 | $ldappagedresults = ldap_paged_results_supported($this->config->ldap_version, $ldapconnection); 125 | $ldapcookie = ''; 126 | foreach ($contexts as $context) { 127 | $context = trim($context); 128 | if (empty($context)) { 129 | continue; 130 | } 131 | 132 | do { 133 | if ($ldappagedresults) { 134 | $servercontrols = array(array( 135 | 'oid' => LDAP_CONTROL_PAGEDRESULTS, 'value' => array( 136 | 'size' => $this->config->pagesize, 'cookie' => $ldapcookie))); 137 | } 138 | if ($this->config->search_sub) { 139 | // Use ldap_search to find first user from subtree. 140 | $ldapresult = ldap_search($ldapconnection, $context, $filter, array($this->config->user_attribute), 141 | 0, -1, -1, LDAP_DEREF_NEVER, $servercontrols); 142 | } else { 143 | // Search only in this context. 144 | $ldapresult = ldap_list($ldapconnection, $context, $filter, array($this->config->user_attribute), 145 | 0, -1, -1, LDAP_DEREF_NEVER, $servercontrols); 146 | } 147 | if(!$ldapresult) { 148 | continue; 149 | } 150 | if ($ldappagedresults) { 151 | // Get next server cookie to know if we'll need to continue searching. 152 | $ldapcookie = ''; 153 | // Get next cookie from controls. 154 | ldap_parse_result($ldapconnection, $ldapresult, $errcode, $matcheddn, 155 | $errmsg, $referrals, $controls); 156 | if (isset($controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'])) { 157 | $ldapcookie = $controls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie']; 158 | } 159 | } 160 | if ($entry = @ldap_first_entry($ldapconnection, $ldapresult)) { 161 | do { 162 | $value = ldap_get_values_len($ldapconnection, $entry, $this->config->user_attribute); 163 | $value = core_text::convert($value[0], $this->config->ldapencoding, 'utf-8'); 164 | $value = trim($value); 165 | $this->ldap_bulk_insert($value); 166 | } while ($entry = ldap_next_entry($ldapconnection, $entry)); 167 | } 168 | unset($ldapresult); // Free mem. 169 | } while ($ldappagedresults && $ldapcookie !== null && $ldapcookie != ''); 170 | } 171 | 172 | // If LDAP paged results were used, the current connection must be completely 173 | // closed and a new one created, to work without paged results from here on. 174 | if ($ldappagedresults) { 175 | $this->ldap_close(true); 176 | $ldapconnection = $this->ldap_connect(); 177 | } 178 | 179 | // Preserve our user database. 180 | // If the temp table is empty, it probably means that something went wrong, exit 181 | // so as to avoid mass deletion of users; which is hard to undo. 182 | $count = $DB->count_records_sql('SELECT COUNT(username) AS count, 1 FROM {tmp_extuser}'); 183 | if ($count < 1) { 184 | mtrace(get_string('didntgetusersfromldap', 'auth_ldap')); 185 | $dbman->drop_table($table); 186 | $this->ldap_close(); 187 | return false; 188 | } else { 189 | mtrace(get_string('gotcountrecordsfromldap', 'auth_ldap', $count)); 190 | } 191 | 192 | 193 | // Non Grace Period Synchronisation. 194 | if ($this->config->removeuser != AUTH_REMOVEUSER_DELETEWITHGRACEPERIOD) { 195 | 196 | // User removal. 197 | // Find users in DB that aren't in ldap -- to be removed! 198 | // this is still not as scalable (but how often do we mass delete?). 199 | 200 | if ($this->config->removeuser == AUTH_REMOVEUSER_FULLDELETE) { 201 | $sql = "SELECT u.* 202 | FROM {user} u 203 | LEFT JOIN {tmp_extuser} e ON (u.username = e.username AND u.mnethostid = e.mnethostid) 204 | WHERE u.auth = :auth 205 | AND u.deleted = 0 206 | AND e.username IS NULL"; 207 | $remove_users = $DB->get_records_sql($sql, array('auth'=>$this->authtype)); 208 | 209 | if (!empty($remove_users)) { 210 | mtrace(get_string('userentriestoremove', 'auth_ldap', count($remove_users))); 211 | 212 | foreach ($remove_users as $user) { 213 | if (delete_user($user)) { 214 | mtrace("\t".get_string('auth_dbdeleteuser', 'auth_db', array('name'=>$user->username, 'id'=>$user->id))); 215 | } else { 216 | mtrace("\t".get_string('auth_dbdeleteusererror', 'auth_db', $user->username)); 217 | } 218 | } 219 | } else { 220 | mtrace(get_string('nouserentriestoremove', 'auth_ldap')); 221 | } 222 | unset($remove_users); // Free mem! 223 | 224 | } else if ($this->config->removeuser == AUTH_REMOVEUSER_SUSPEND) { 225 | $sql = "SELECT u.* 226 | FROM {user} u 227 | LEFT JOIN {tmp_extuser} e ON (u.username = e.username AND u.mnethostid = e.mnethostid) 228 | WHERE u.auth = :auth 229 | AND u.deleted = 0 230 | AND u.suspended = 0 231 | AND e.username IS NULL"; 232 | $remove_users = $DB->get_records_sql($sql, array('auth'=>$this->authtype)); 233 | 234 | if (!empty($remove_users)) { 235 | mtrace(get_string('userentriestoremove', 'auth_ldap', count($remove_users))); 236 | 237 | foreach ($remove_users as $user) { 238 | $updateuser = new stdClass(); 239 | $updateuser->id = $user->id; 240 | $updateuser->suspended = 1; 241 | user_update_user($updateuser, false); 242 | mtrace("\t".get_string('auth_dbsuspenduser', 'auth_db', array('name'=>$user->username, 'id'=>$user->id))); 243 | \core\session\manager::destroy_user_sessions($user->id); 244 | } 245 | } else { 246 | mtrace(get_string('nouserentriestoremove', 'auth_ldap')); 247 | } 248 | unset($remove_users); // Free mem! 249 | } 250 | 251 | // Revive suspended users. 252 | if (!empty($this->config->removeuser) and $this->config->removeuser == AUTH_REMOVEUSER_SUSPEND) { 253 | $sql = "SELECT u.id, u.username 254 | FROM {user} u 255 | JOIN {tmp_extuser} e ON (u.username = e.username AND u.mnethostid = e.mnethostid) 256 | WHERE (u.auth = 'nologin' OR (u.auth = ? AND u.suspended = 1)) AND u.deleted = 0"; 257 | // Note: 'nologin' is there for backwards compatibility. 258 | $revive_users = $DB->get_records_sql($sql, array($this->authtype)); 259 | 260 | if (!empty($revive_users)) { 261 | mtrace(get_string('userentriestorevive', 'auth_ldap', count($revive_users))); 262 | 263 | foreach ($revive_users as $user) { 264 | $updateuser = new stdClass(); 265 | $updateuser->id = $user->id; 266 | $updateuser->auth = $this->authtype; 267 | $updateuser->suspended = 0; 268 | user_update_user($updateuser, false); 269 | mtrace("\t".get_string('auth_dbreviveduser', 'auth_db', array('name'=>$user->username, 'id'=>$user->id))); 270 | } 271 | } else { 272 | mtrace(get_string('nouserentriestorevive', 'auth_ldap')); 273 | } 274 | 275 | unset($revive_users); 276 | } 277 | } 278 | 279 | // Grace Period Synchronisation. 280 | else if (!empty($this->config->removeuser) and $this->config->removeuser == AUTH_REMOVEUSER_DELETEWITHGRACEPERIOD) { 281 | 282 | // Revive suspended users. 283 | $sql = "SELECT u.id, u.username 284 | FROM {user} u 285 | JOIN {tmp_extuser} e ON (u.username = e.username AND u.mnethostid = e.mnethostid) 286 | WHERE (u.auth = 'nologin' OR (u.auth = ? AND u.suspended = 1)) AND u.deleted = 0"; 287 | // Note: 'nologin' is there for backwards compatibility. 288 | $revive_users = $DB->get_records_sql($sql, array($this->authtype)); 289 | 290 | if (!empty($revive_users)) { 291 | mtrace(get_string('userentriestorevive', 'auth_ldap', count($revive_users))); 292 | 293 | foreach ($revive_users as $user) { 294 | $updateuser = new stdClass(); 295 | $updateuser->id = $user->id; 296 | $updateuser->auth = $this->authtype; 297 | $updateuser->suspended = 0; 298 | user_update_user($updateuser, false); 299 | mtrace("\t".get_string('auth_dbreviveduser', 'auth_db', array('name'=>$user->username, 'id'=>$user->id))); 300 | } 301 | } else { 302 | mtrace(get_string('nouserentriestorevive', 'auth_ldap')); 303 | } 304 | unset($revive_users); 305 | 306 | // User temporary suspending. 307 | $sql = "SELECT u.* 308 | FROM {user} u 309 | LEFT JOIN {tmp_extuser} e ON (u.username = e.username AND u.mnethostid = e.mnethostid) 310 | WHERE u.auth = :auth 311 | AND u.deleted = 0 312 | AND u.suspended = 0 313 | AND e.username IS NULL"; 314 | $remove_users = $DB->get_records_sql($sql, array('auth'=>$this->authtype)); 315 | 316 | if (!empty($remove_users)) { 317 | mtrace(get_string('userentriestosuspend', 'auth_ldap_syncplus', count($remove_users))); 318 | 319 | foreach ($remove_users as $user) { 320 | $updateuser = new stdClass(); 321 | $updateuser->id = $user->id; 322 | $updateuser->suspended = 1; 323 | $updateuser->timemodified = time(); // Remember suspend time, abuse timemodified column for this. 324 | user_update_user($updateuser, false); 325 | mtrace("\t".get_string('auth_dbsuspenduser', 'auth_db', array('name'=>$user->username, 'id'=>$user->id))); 326 | \core\session\manager::destroy_user_sessions($user->id); 327 | } 328 | } else { 329 | mtrace(get_string('nouserentriestosuspend', 'auth_ldap_syncplus')); 330 | } 331 | unset($remove_users); // Free mem! 332 | 333 | // User complete removal. 334 | $sql = "SELECT u.* 335 | FROM {user} u 336 | LEFT JOIN {tmp_extuser} e ON (u.username = e.username AND u.mnethostid = e.mnethostid) 337 | WHERE u.auth = :auth 338 | AND u.deleted = 0 339 | AND e.username IS NULL"; 340 | $remove_users = $DB->get_records_sql($sql, array('auth'=>$this->authtype)); 341 | 342 | if (!empty($remove_users)) { 343 | mtrace(get_string('userentriestoremove', 'auth_ldap', count($remove_users))); 344 | 345 | foreach ($remove_users as $user) { 346 | // Do only if user was suspended before grace period. 347 | $graceperiod = max(intval($this->config->removeuser_graceperiod), 0); 348 | // Fix problems if grace period setting was negative or no number. 349 | if (time() - $user->timemodified >= $graceperiod * 24 * 3600) { 350 | if (delete_user($user)) { 351 | mtrace("\t".get_string('auth_dbdeleteuser', 'auth_db', array('name'=>$user->username, 'id'=>$user->id))); 352 | } else { 353 | mtrace("\t".get_string('auth_dbdeleteusererror', 'auth_db', $user->username)); 354 | } 355 | // Otherwise inform about ongoing grace period. 356 | } else { 357 | mtrace("\t".get_string('waitinginremovalqueue', 'auth_ldap_syncplus', array('days'=>$graceperiod, 'name'=>$user->username, 'id'=>$user->id))); 358 | } 359 | } 360 | } else { 361 | mtrace(get_string('nouserentriestoremove', 'auth_ldap')); 362 | } 363 | unset($remove_users); // Free mem! 364 | } 365 | 366 | // User Updates - time-consuming (optional). 367 | if ($updatecallback && $updatekeys = $this->get_profile_keys()) { // Run updates only if relevant. 368 | $users = $DB->get_records_sql('SELECT u.username, u.id 369 | FROM {user} u 370 | WHERE u.deleted = 0 AND u.auth = ? AND u.mnethostid = ?', 371 | array($this->authtype, $CFG->mnet_localhost_id)); 372 | if (!empty($users)) { 373 | // Update users in chunks as specified in sync_updateuserchunk. 374 | if (!empty($this->config->sync_updateuserchunk)) { 375 | foreach (array_chunk($users, $this->config->sync_updateuserchunk) as $chunk) { 376 | call_user_func($updatecallback, $chunk, $updatekeys); 377 | } 378 | } else { 379 | call_user_func($updatecallback, $users, $updatekeys); 380 | } 381 | unset($users); // Free mem. 382 | } 383 | } else { 384 | mtrace(get_string('noupdatestobedone', 'auth_ldap')); 385 | } 386 | 387 | // User Additions. 388 | // Find users missing in DB that are in LDAP 389 | // and gives me a nifty object I don't want. 390 | // note: we do not care about deleted accounts anymore, this feature was replaced by suspending to nologin auth plugin. 391 | if (!empty($this->config->sync_script_createuser_enabled) and $this->config->sync_script_createuser_enabled == 1) { 392 | $sql = 'SELECT e.id, e.username 393 | FROM {tmp_extuser} e 394 | LEFT JOIN {user} u ON (e.username = u.username AND e.mnethostid = u.mnethostid) 395 | WHERE u.id IS NULL'; 396 | $add_users = $DB->get_records_sql($sql); 397 | 398 | if (!empty($add_users)) { 399 | mtrace(get_string('userentriestoadd', 'auth_ldap', count($add_users))); 400 | $errors = 0; 401 | 402 | foreach ($add_users as $user) { 403 | $transaction = $DB->start_delegated_transaction(); 404 | $user = $this->get_userinfo_asobj($user->username); 405 | 406 | // Prep a few params. 407 | $user->modified = time(); 408 | $user->confirmed = 1; 409 | $user->auth = $this->authtype; 410 | $user->mnethostid = $CFG->mnet_localhost_id; 411 | // get_userinfo_asobj() might have replaced $user->username with the value 412 | // from the LDAP server (which can be mixed-case). Make sure it's lowercase. 413 | $user->username = trim(core_text::strtolower($user->username)); 414 | // It isn't possible to just rely on the configured suspension attribute since 415 | // things like active directory use bit masks, other things using LDAP might 416 | // do different stuff as well. 417 | // 418 | // The cast to int is a workaround for MDL-53959. 419 | $user->suspended = (int)$this->is_user_suspended($user); 420 | 421 | if (empty($user->calendartype)) { 422 | $user->calendartype = $CFG->calendartype; 423 | } 424 | 425 | // $id = user_create_user($user, false); 426 | try { 427 | $id = user_create_user($user, false); 428 | } catch (Exception $e) { 429 | mtrace(get_string('invaliduserexception', 'auth_ldap', print_r($user, true) . $e->getMessage())); 430 | $errors++; 431 | $transaction->allow_commit(); 432 | continue; 433 | } 434 | mtrace("\t".get_string('auth_dbinsertuser', 'auth_db', array('name'=>$user->username, 'id'=>$id))); 435 | $euser = $DB->get_record('user', array('id' => $id)); 436 | 437 | if (!empty($this->config->forcechangepassword)) { 438 | set_user_preference('auth_forcepasswordchange', 1, $id); 439 | } 440 | 441 | // Save custom profile fields. 442 | $this->update_user_record($user->username, $this->get_profile_keys(true), false); 443 | 444 | // Add roles if needed. 445 | $this->sync_roles($euser); 446 | $transaction->allow_commit(); 447 | } 448 | 449 | // Display number of user creation errors, if any. 450 | if ($errors) { 451 | mtrace(get_string('invalidusererrors', 'auth_ldap', $errors)); 452 | } 453 | 454 | unset($add_users); // free mem 455 | } else { 456 | mtrace(get_string('nouserstobeadded', 'auth_ldap')); 457 | } 458 | } else { 459 | mtrace(get_string('nouserstobeadded', 'auth_ldap')); 460 | } 461 | 462 | $dbman->drop_table($table); 463 | $this->ldap_close(); 464 | 465 | return true; 466 | } 467 | 468 | /** 469 | * Update users from the external LDAP server into Moodle's user table. 470 | * 471 | * Sync helper 472 | * 473 | * @param array $users chunk of users to update 474 | * @param array $updatekeys fields to update 475 | */ 476 | public function update_users(array $users, array $updatekeys): void { 477 | global $DB; 478 | 479 | mtrace(get_string('userentriestoupdate', 'auth_ldap', count($users))); 480 | 481 | foreach ($users as $user) { 482 | $transaction = $DB->start_delegated_transaction(); 483 | echo "\t"; 484 | print_string('auth_dbupdatinguser', 'auth_db', ['name' => $user->username, 'id' => $user->id]); 485 | $userinfo = $this->get_userinfo($user->username); 486 | if (!$this->update_user_record($user->username, $updatekeys, true, 487 | $this->is_user_suspended((object) $userinfo))) { 488 | echo ' - '.get_string('skipped'); 489 | } 490 | echo "\n"; 491 | 492 | // Update system roles, if needed. 493 | $this->sync_roles($user); 494 | $transaction->allow_commit(); 495 | } 496 | } 497 | 498 | /** 499 | * Support login via email ($CFG->authloginviaemail) for first-time LDAP logins 500 | * @return void 501 | */ 502 | public function loginpage_hook() { 503 | global $CFG, $frm, $DB; 504 | 505 | // If $CFG->authloginviaemail is not set, users don't want to login by mail, call parent hook and return. 506 | if ($CFG->authloginviaemail != 1) { 507 | parent::loginpage_hook(); // Call parent function to retain its functionality. 508 | return; 509 | } 510 | 511 | // Get submitted form data. 512 | $frm = data_submitted(); 513 | 514 | // If there is no username submitted, there's nothing to do, call parent hook and return. 515 | if (empty($frm->username)) { 516 | parent::loginpage_hook(); // Call parent function to retain its functionality. 517 | return; 518 | } 519 | 520 | // Clean username parameter to make sure that its an email address. 521 | $email = clean_param($frm->username, PARAM_EMAIL); 522 | 523 | // If we don't have an email adress, there's nothing to do, call parent hook and return. 524 | if ($email == '' || strpos($email, '@') == false) { 525 | parent::loginpage_hook(); // Call parent function to retain its functionality. 526 | return; 527 | } 528 | 529 | // If there is an existing useraccount with this email adress as email address (then a Moodle account already exists and 530 | // the standard mechanism of $CFG->authloginviaemail will kick in automatically) or if there is an existing useraccount 531 | // with this email adress as username (which is not forbidden, so this useraccount has to be used), call parent hook and 532 | // return. 533 | if ($DB->count_records_select('user', '(username = :p1 OR email = :p2) AND deleted = 0', 534 | array('p1' => $email, 'p2' => $email)) > 0) { 535 | parent::loginpage_hook(); // Call parent function to retain its functionality. 536 | return; 537 | } 538 | 539 | // Get auth plugin. 540 | $authplugin = get_auth_plugin('ldap_syncplus'); 541 | 542 | // If there is no email field mapping configured, we don't know where we can find the email adress in LDAP, 543 | // call parent hook and return. 544 | if (empty($authplugin->config->field_map_email)) { 545 | parent::loginpage_hook(); // Call parent function to retain its functionality. 546 | return; 547 | } 548 | 549 | // Prepare LDAP search. 550 | $contexts = explode(';', $authplugin->config->contexts); 551 | $filter = '(&('.$authplugin->config->field_map_email.'='.ldap_filter_addslashes($email).')'. 552 | $authplugin->config->objectclass.')'; 553 | 554 | // Connect to LDAP. 555 | $ldapconnection = $authplugin->ldap_connect(); 556 | 557 | // Array for saving the user's ids which are found in the configured LDAP contexts. 558 | $uidsfound = array(); 559 | 560 | // Look for users matching the given email adress in LDAP. 561 | foreach ($contexts as $context) { 562 | // Verify that the given context is valid. 563 | $context = trim($context); 564 | if (empty($context)) { 565 | continue; 566 | } 567 | 568 | // Search LDAP. 569 | if ($authplugin->config->search_sub) { 570 | // Use ldap_search to find first user from subtree. 571 | $ldapresult = ldap_search($ldapconnection, $context, $filter, array($authplugin->config->user_attribute)); 572 | } else { 573 | // Search only in this context. 574 | $ldapresult = ldap_list($ldapconnection, $context, $filter, array($authplugin->config->user_attribute)); 575 | } 576 | 577 | // If there is no LDAP result or if the user was not found in this context, continue with next context. 578 | if (!$ldapresult || ldap_count_entries($ldapconnection, $ldapresult) == 0) { 579 | continue; 580 | } 581 | 582 | // If there is not exactly one matching user, we can't continue, call parent hook and return. 583 | if (ldap_count_entries($ldapconnection, $ldapresult) != 1) { 584 | parent::loginpage_hook(); // Call parent function to retain its functionality. 585 | return; 586 | } 587 | 588 | // Get this one matching user entry. 589 | if (!$ldapentry = ldap_first_entry($ldapconnection, $ldapresult)) { 590 | parent::loginpage_hook(); // Call parent function to retain its functionality. 591 | return; 592 | } 593 | 594 | // Get the uid attribute's value(s) from this user entry. 595 | $values = ldap_get_values($ldapconnection, $ldapentry, $authplugin->config->user_attribute); 596 | 597 | // If there is not exactly one copy of the uid attribute in the LDAP user entry, we don't know which one to use, 598 | // call parent hook and return. 599 | if ($values['count'] != 1) { 600 | parent::loginpage_hook(); // Call parent function to retain its functionality. 601 | return; 602 | } 603 | 604 | // Remember this one user's uid attribute. 605 | $uidsfound[] = $values[0]; 606 | 607 | unset($ldapresult); // Free mem! 608 | } 609 | 610 | // After we have checked all contexts, verify that we have found only one user in total. 611 | // If not, we can't continue, call parent hook and return. 612 | if (count($uidsfound) != 1) { 613 | parent::loginpage_hook(); // Call parent function to retain its functionality. 614 | return; 615 | 616 | // Success! 617 | // Replace the form data's username with the user attribute from LDAP, it will be held in the global $frm variable. 618 | } else { 619 | $frm->username = $uidsfound[0]; 620 | parent::loginpage_hook(); // Call parent function to retain its functionality. 621 | return; 622 | } 623 | } 624 | } 625 | -------------------------------------------------------------------------------- /classes/eventobservers.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Auth plugin "LDAP SyncPlus" - Event observers 19 | * 20 | * @package auth_ldap_syncplus 21 | * @copyright 2014 Alexander Bias, Ulm University 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | 25 | namespace auth_ldap_syncplus; 26 | 27 | use moodle_exception; 28 | 29 | /** 30 | * Observer class containing methods monitoring various events. 31 | * 32 | * @package auth_ldap_syncplus 33 | * @copyright 2014 Alexander Bias, Ulm University 34 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 | */ 36 | class eventobservers { 37 | /** 38 | * User created event observer. 39 | * 40 | * @param \core\event\base $event The event that triggered the handler. 41 | */ 42 | public static function user_created(\core\event\base $event) { 43 | global $DB; 44 | 45 | // Do only if user id is enclosed in $eventdata. 46 | if (!empty($event->relateduserid)) { 47 | 48 | // Get user data. 49 | $user = $DB->get_record('user', ['id' => $event->relateduserid]); 50 | 51 | // Do if user was found. 52 | if (!empty($user->username)) { 53 | 54 | // Do only if user has ldap_syncplus authentication. 55 | if (isset($user->auth) && $user->auth == 'ldap_syncplus') { 56 | 57 | // Update user. 58 | // Actually, we would want to call auth_plugin_base::update_user_record() 59 | // which is lighter, but this function is unfortunately protected since Moodle 3.5. 60 | update_user_record($user->username); 61 | } 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /classes/privacy/provider.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Auth plugin "LDAP SyncPlus" - Privacy provider 19 | * 20 | * @package auth_ldap_syncplus 21 | * @copyright 2018 Alexander Bias, Ulm University 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | 25 | namespace auth_ldap_syncplus\privacy; 26 | 27 | /** 28 | * Privacy Subsystem implementing null_provider. 29 | * 30 | * @package auth_ldap_syncplus 31 | * @copyright 2018 Alexander Bias, Ulm University 32 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 33 | */ 34 | class provider implements \core_privacy\local\metadata\null_provider { 35 | 36 | /** 37 | * Get the language string identifier with the component's language 38 | * file to explain why this plugin stores no data. 39 | * 40 | * @return string 41 | */ 42 | public static function get_reason(): string { 43 | return 'privacy:metadata'; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /classes/task/asynchronous_sync_task.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Auth plugin "LDAP SyncPlus" - Ad-hoc task definition 19 | * 20 | * @package auth_ldap_syncplus 21 | * @copyright 2024 Alexander Bias, ssystems GmbH 22 | * based on code by Catalyst IT 23 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 | */ 25 | 26 | namespace auth_ldap_syncplus\task; 27 | 28 | use core\task\adhoc_task; 29 | 30 | /** 31 | * The auth_ldap_syncplus ad-hoc task class for LDAP user update 32 | * 33 | * @package auth_ldap_syncplus 34 | * @copyright 2024 Alexander Bias, ssystems GmbH 35 | * based on code by Catalyst IT 36 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 37 | */ 38 | class asynchronous_sync_task extends adhoc_task { 39 | /** @var string Message prefix for mtrace */ 40 | protected const MTRACE_MSG = 'Synced LDAP (Sync Plus) users'; 41 | 42 | /** 43 | * Constructor 44 | */ 45 | public function __construct() { 46 | $this->set_component('auth_ldap_syncplus'); 47 | } 48 | 49 | /** 50 | * Run users sync. 51 | */ 52 | public function execute() { 53 | $data = $this->get_custom_data(); 54 | 55 | /** @var auth_plugin_ldap $auth */ 56 | $auth = get_auth_plugin('ldap_syncplus'); 57 | $auth->update_users($data->users, $data->updatekeys); 58 | 59 | mtrace(sprintf(" %s (%d)", self::MTRACE_MSG, count($data->users))); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /classes/task/sync_roles.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Auth plugin "LDAP SyncPlus" - Task definition 19 | * 20 | * @package auth_ldap_syncplus 21 | * @copyright 2014 Alexander Bias, Ulm University 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | 25 | namespace auth_ldap_syncplus\task; 26 | 27 | /** 28 | * The auth_ldap_syncplus scheduled task class for LDAP roles sync 29 | * 30 | * @package auth_ldap_syncplus 31 | * @copyright 2014 Alexander Bias, Ulm University 32 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 33 | */ 34 | class sync_roles extends \core\task\scheduled_task { 35 | 36 | /** 37 | * Return localised task name. 38 | * 39 | * @return string 40 | */ 41 | public function get_name() { 42 | return get_string('syncroles', 'auth_ldap_syncplus'); 43 | } 44 | 45 | /** 46 | * Execute scheduled task 47 | * 48 | * @return boolean 49 | */ 50 | public function execute() { 51 | global $DB; 52 | if (is_enabled_auth('ldap_syncplus')) { 53 | $auth = get_auth_plugin('ldap_syncplus'); 54 | $users = $DB->get_records('user', ['auth' => 'ldap_syncplus']); 55 | foreach ($users as $user) { 56 | $auth->sync_roles($user); 57 | } 58 | } 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /classes/task/sync_task.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Auth plugin "LDAP SyncPlus" - Task definition 19 | * 20 | * @package auth_ldap_syncplus 21 | * @copyright 2024 Alexander Bias, ssystems GmbH 22 | * based on code by Catalyst IT 23 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 | */ 25 | 26 | namespace auth_ldap_syncplus\task; 27 | 28 | /** 29 | * The auth_ldap_syncplus scheduled task class for LDAP user sync 30 | * 31 | * @package auth_ldap_syncplus 32 | * @copyright 2024 Alexander Bias, ssystems GmbH 33 | * based on code by Catalyst IT 34 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 | */ 36 | class sync_task extends \core\task\scheduled_task { 37 | /** @var string Message prefix for mtrace */ 38 | protected const MTRACE_MSG = 'Synced LDAP (Sync Plus) users'; 39 | 40 | /** 41 | * Return localised task name. 42 | * 43 | * @return string 44 | */ 45 | public function get_name() { 46 | return get_string('synctask', 'auth_ldap_syncplus'); 47 | } 48 | 49 | /** 50 | * Execute scheduled task 51 | * 52 | * @return boolean 53 | */ 54 | public function execute() { 55 | if (is_enabled_auth('ldap_syncplus')) { 56 | /** @var auth_plugin_ldap_syncplus $auth */ 57 | $auth = get_auth_plugin('ldap_syncplus'); 58 | $count = 0; 59 | $auth->sync_users_update_callback(function ($users, $updatekeys) use (&$count) { 60 | $asynctask = new asynchronous_sync_task(); 61 | $asynctask->set_custom_data([ 62 | 'users' => $users, 63 | 'updatekeys' => $updatekeys, 64 | ]); 65 | \core\task\manager::queue_adhoc_task($asynctask); 66 | 67 | $count++; 68 | mtrace(sprintf(" %s (%d)", self::MTRACE_MSG, $count)); 69 | sleep(1); 70 | }); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /cli/sync_users.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Auth plugin "LDAP SyncPlus" - CLI Script 19 | * 20 | * @package auth_ldap_syncplus 21 | * @copyright 2014 Alexander Bias, Ulm University 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | 25 | define('CLI_SCRIPT', true); 26 | 27 | // phpcs:disable 28 | // Let codechecker ignore this file. This code mostly re-used from auth_ldap and the problems are already there and not made by us. 29 | 30 | require(__DIR__.'/../../../config.php'); // global moodle config file. 31 | require_once($CFG->dirroot.'/course/lib.php'); 32 | require_once($CFG->libdir.'/clilib.php'); 33 | 34 | // Ensure errors are well explained 35 | set_debugging(DEBUG_DEVELOPER, true); 36 | 37 | if (!is_enabled_auth('ldap_syncplus')) { 38 | error_log('[AUTH LDAP SYNCPLUS] '.get_string('pluginnotenabled', 'auth_ldap')); 39 | die; 40 | } 41 | 42 | cli_problem('[AUTH LDAP SYNCPLUS] The users sync cron has been deprecated. Please use the scheduled task instead.'); 43 | 44 | // Abort execution of the CLI script if the auth_ldap_syncplus\task\sync_task is enabled. 45 | $taskdisabled = \core\task\manager::get_scheduled_task('auth_ldap_syncplus\task\sync_task'); 46 | if (!$taskdisabled->get_disabled()) { 47 | cli_error('[AUTH LDAP SYNCPLUS] The scheduled task sync_task is enabled, the cron execution has been aborted.'); 48 | } 49 | 50 | $ldapauth = get_auth_plugin('ldap_syncplus'); 51 | $ldapauth->sync_users(true); 52 | 53 | -------------------------------------------------------------------------------- /db/events.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Auth plugin "LDAP SyncPlus" - Event definition 19 | * 20 | * @package auth_ldap_syncplus 21 | * @copyright 2014 Alexander Bias, Ulm University 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | 25 | defined('MOODLE_INTERNAL') || die(); 26 | 27 | $observers = [ 28 | [ 29 | 'eventname' => '\core\event\user_created', 30 | 'callback' => '\auth_ldap_syncplus\eventobservers::user_created', 31 | ], 32 | ]; 33 | -------------------------------------------------------------------------------- /db/tasks.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Auth plugin "LDAP SyncPlus" - Scheduled tasks 19 | * 20 | * @package auth_ldap_syncplus 21 | * @copyright 2014 Alexander Bias, Ulm University 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | 25 | defined('MOODLE_INTERNAL') || die(); 26 | 27 | $tasks = [ 28 | [ 29 | 'classname' => 'auth_ldap_syncplus\task\sync_roles', 30 | 'blocking' => 0, 31 | 'minute' => '0', 32 | 'hour' => '0', 33 | 'day' => '*', 34 | 'month' => '*', 35 | 'dayofweek' => '*', 36 | 'disabled' => 1, 37 | ], 38 | [ 39 | 'classname' => 'auth_ldap_syncplus\task\sync_task', 40 | 'blocking' => 0, 41 | 'minute' => '0', 42 | 'hour' => '0', 43 | 'day' => '*', 44 | 'month' => '*', 45 | 'dayofweek' => '*', 46 | 'disabled' => 1, 47 | ], 48 | ]; 49 | -------------------------------------------------------------------------------- /db/upgrade.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Auth plugin "LDAP SyncPlus" - Upgrade script 19 | * 20 | * @package auth_ldap_syncplus 21 | * @copyright 2014 Alexander Bias, Ulm University 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | 25 | /** 26 | * Function to upgrade auth_ldap_syncplus. 27 | * @param int $oldversion the version we are upgrading from 28 | * @return bool result 29 | */ 30 | function xmldb_auth_ldap_syncplus_upgrade($oldversion) { 31 | global $DB; 32 | 33 | if ($oldversion < 2018020200) { 34 | // Convert info in config plugins from auth/ldap_syncplus to auth_ldap_syncplus. 35 | upgrade_fix_config_auth_plugin_names('ldap_syncplus'); 36 | upgrade_fix_config_auth_plugin_defaults('ldap_syncplus'); 37 | upgrade_plugin_savepoint(true, 2018020200, 'auth', 'ldap_syncplus'); 38 | } 39 | 40 | if ($oldversion < 2018020601) { 41 | // The "auth_ldap_syncplus/coursecreators" setting was replaced with "auth_ldap_syncplus/coursecreatorcontext" (created 42 | // dynamically from system-assignable roles) - so migrate any existing value to the first new slot. 43 | if ($ldapcontext = get_config('auth_ldap_syncplus', 'creators')) { 44 | // Get info about the role that the old coursecreators setting would apply. 45 | $creatorrole = get_archetype_roles('coursecreator'); 46 | $creatorrole = array_shift($creatorrole); // We can only use one, let's use the first. 47 | // Create new setting. 48 | set_config($creatorrole->shortname . 'context', $ldapcontext, 'auth_ldap_syncplus'); 49 | // Delete old setting. 50 | set_config('creators', null, 'auth_ldap_syncplus'); 51 | upgrade_plugin_savepoint(true, 2018020601, 'auth', 'ldap_syncplus'); 52 | } 53 | } 54 | 55 | if ($oldversion < 2021072003) { 56 | // Normalize the memberattribute_isdn plugin config. 57 | set_config('memberattribute_isdn', 58 | !empty(get_config('auth_ldap_syncplus', 'memberattribute_isdn')), 'auth_ldap'); 59 | 60 | upgrade_plugin_savepoint(true, 2021072003, 'auth', 'ldap_syncplus'); 61 | } 62 | 63 | return true; 64 | } 65 | -------------------------------------------------------------------------------- /lang/en/auth_ldap_syncplus.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Auth plugin "LDAP SyncPlus" - Language pack 19 | * 20 | * @package auth_ldap_syncplus 21 | * @copyright 2014 Alexander Bias, Ulm University 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | 25 | $string['auth_ldap_syncplusdescription'] = 'This method provides authentication against an external LDAP server. 26 | If the given username and password are valid, Moodle creates a new user 27 | entry in its database. This module can read user attributes from LDAP and prefill 28 | wanted fields in Moodle. For following logins only the username and 29 | password are checked.'; 30 | $string['auth_remove_deletewithgraceperiod'] = 'Suspend internal and fully delete internal after grace period'; 31 | $string['nouserentriestosuspend'] = 'No user entries to be suspended'; 32 | $string['pluginname'] = 'LDAP server (Sync Plus)'; 33 | $string['privacy:metadata'] = 'The LDAP server (Sync Plus) authentication plugin does not store any personal data.'; 34 | $string['removeuser_graceperiod'] = 'Fully deleting grace period'; 35 | $string['removeuser_graceperiod_desc'] = 'After suspending a user internally, the synchronization script will wait for this number of days until the user will be fully deleted internal. If the user re-appears in LDAP within this grace period, the user will be reactivated. Note: This setting is only used if "Removed ext user" is set to "Suspend internal and fully delete internal after grace period"'; 36 | $string['sync_script_createuser_enabled'] = 'If enabled (default), the synchronization script will create Moodle accounts for all LDAP users if they have never logged into Moodle before. If disabled, the synchronization script will not create Moodle accounts for all LDAP users.'; 37 | $string['sync_script_createuser_enabled_key'] = 'Add new users'; 38 | $string['syncroles'] = 'LDAP roles sync job (Sync Plus)'; 39 | $string['synctask'] = 'LDAP users sync job (Sync Plus)'; 40 | $string['userentriestosuspend'] = 'User entries to be suspended: {$a}'; 41 | $string['waitinginremovalqueue'] = 'Waiting in removal queue for {$a->days} day grace period: {$a->name} ID {$a->id}'; 42 | -------------------------------------------------------------------------------- /locallib.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Auth plugin "LDAP SyncPlus" - Local library 19 | * 20 | * @package auth_ldap_syncplus 21 | * @copyright 2014 Alexander Bias, Ulm University 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | 25 | define('AUTH_REMOVEUSER_DELETEWITHGRACEPERIOD', 3); 26 | -------------------------------------------------------------------------------- /settings.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Auth plugin "LDAP SyncPlus" - Settings 19 | * 20 | * @package auth_ldap_syncplus 21 | * @copyright 2014 Alexander Bias, Ulm University 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | 25 | use core\lang_string; 26 | 27 | defined('MOODLE_INTERNAL') || die; 28 | 29 | if ($ADMIN->fulltree) { 30 | 31 | if (!function_exists('ldap_connect')) { 32 | $notify = new \core\output\notification(get_string('auth_ldap_noextension', 'auth_ldap'), 33 | \core\output\notification::NOTIFY_WARNING); 34 | $settings->add(new admin_setting_heading('auth_ldap_noextension', '', $OUTPUT->render($notify))); 35 | } else { 36 | 37 | // We use a couple of custom admin settings since we need to massage the data before it is inserted into the DB. 38 | require_once($CFG->dirroot.'/auth/ldap/classes/admin_setting_special_lowercase_configtext.php'); 39 | require_once($CFG->dirroot.'/auth/ldap/classes/admin_setting_special_contexts_configtext.php'); 40 | require_once($CFG->dirroot.'/auth/ldap/classes/admin_setting_special_ntlm_configtext.php'); 41 | 42 | // We need to use some of the Moodle LDAP constants / functions to create the list of options. 43 | require_once($CFG->dirroot.'/auth/ldap/auth.php'); 44 | 45 | // We need to use some of the Moodle LDAP Syncplus constants / functions to create the list of options. 46 | require_once($CFG->dirroot.'/auth/ldap_syncplus/locallib.php'); 47 | 48 | // Introductory explanation. 49 | $settings->add(new admin_setting_heading('auth_ldap_syncplus/pluginname', '', 50 | new lang_string('auth_ldapdescription', 'auth_ldap'))); 51 | 52 | // LDAP server settings. 53 | $settings->add(new admin_setting_heading('auth_ldap_syncplus/ldapserversettings', 54 | new lang_string('auth_ldap_server_settings', 'auth_ldap'), '')); 55 | 56 | // Host. 57 | $settings->add(new admin_setting_configtext('auth_ldap_syncplus/host_url', 58 | get_string('auth_ldap_host_url_key', 'auth_ldap'), 59 | get_string('auth_ldap_host_url', 'auth_ldap'), '', PARAM_RAW_TRIMMED)); 60 | 61 | // Version. 62 | $versions = []; 63 | $versions[2] = '2'; 64 | $versions[3] = '3'; 65 | $settings->add(new admin_setting_configselect('auth_ldap_syncplus/ldap_version', 66 | new lang_string('auth_ldap_version_key', 'auth_ldap'), 67 | new lang_string('auth_ldap_version', 'auth_ldap'), 3, $versions)); 68 | 69 | // Start TLS. 70 | $yesno = [ 71 | new lang_string('no'), 72 | new lang_string('yes'), 73 | ]; 74 | $settings->add(new admin_setting_configselect('auth_ldap_syncplus/start_tls', 75 | new lang_string('start_tls_key', 'auth_ldap'), 76 | new lang_string('start_tls', 'auth_ldap'), 0 , $yesno)); 77 | 78 | 79 | // Encoding. 80 | $settings->add(new admin_setting_configtext('auth_ldap_syncplus/ldapencoding', 81 | get_string('auth_ldap_ldap_encoding_key', 'auth_ldap'), 82 | get_string('auth_ldap_ldap_encoding', 'auth_ldap'), 'utf-8', PARAM_RAW_TRIMMED)); 83 | 84 | // Page Size. (Hide if not available). 85 | $settings->add(new admin_setting_configtext('auth_ldap_syncplus/pagesize', 86 | get_string('pagesize_key', 'auth_ldap'), 87 | get_string('pagesize', 'auth_ldap'), '250', PARAM_INT)); 88 | 89 | // Bind settings. 90 | $settings->add(new admin_setting_heading('auth_ldap_syncplus/ldapbindsettings', 91 | new lang_string('auth_ldap_bind_settings', 'auth_ldap'), '')); 92 | 93 | // Store Password in DB. 94 | $settings->add(new admin_setting_configselect('auth_ldap_syncplus/preventpassindb', 95 | new lang_string('auth_ldap_preventpassindb_key', 'auth_ldap'), 96 | new lang_string('auth_ldap_preventpassindb', 'auth_ldap'), 0 , $yesno)); 97 | 98 | // User ID. 99 | $settings->add(new admin_setting_configtext('auth_ldap_syncplus/bind_dn', 100 | get_string('auth_ldap_bind_dn_key', 'auth_ldap'), 101 | get_string('auth_ldap_bind_dn', 'auth_ldap'), '', PARAM_RAW_TRIMMED)); 102 | 103 | // Password. 104 | $settings->add(new admin_setting_configpasswordunmask('auth_ldap_syncplus/bind_pw', 105 | get_string('auth_ldap_bind_pw_key', 'auth_ldap'), 106 | get_string('auth_ldap_bind_pw', 'auth_ldap'), '')); 107 | 108 | // User Lookup settings. 109 | $settings->add(new admin_setting_heading('auth_ldap_syncplus/ldapuserlookup', 110 | new lang_string('auth_ldap_user_settings', 'auth_ldap'), '')); 111 | 112 | // User Type. 113 | $settings->add(new admin_setting_configselect('auth_ldap_syncplus/user_type', 114 | new lang_string('auth_ldap_user_type_key', 'auth_ldap'), 115 | new lang_string('auth_ldap_user_type', 'auth_ldap'), 'default', ldap_supported_usertypes())); 116 | 117 | // Contexts. 118 | $settings->add(new auth_ldap_admin_setting_special_contexts_configtext('auth_ldap_syncplus/contexts', 119 | get_string('auth_ldap_contexts_key', 'auth_ldap'), 120 | get_string('auth_ldap_contexts', 'auth_ldap'), '', PARAM_RAW_TRIMMED)); 121 | 122 | // Search subcontexts. 123 | $settings->add(new admin_setting_configselect('auth_ldap_syncplus/search_sub', 124 | new lang_string('auth_ldap_search_sub_key', 'auth_ldap'), 125 | new lang_string('auth_ldap_search_sub', 'auth_ldap'), 0 , $yesno)); 126 | 127 | // Dereference aliases. 128 | $optderef = []; 129 | $optderef[LDAP_DEREF_NEVER] = get_string('no'); 130 | $optderef[LDAP_DEREF_ALWAYS] = get_string('yes'); 131 | 132 | $settings->add(new admin_setting_configselect('auth_ldap_syncplus/opt_deref', 133 | new lang_string('auth_ldap_opt_deref_key', 'auth_ldap'), 134 | new lang_string('auth_ldap_opt_deref', 'auth_ldap'), LDAP_DEREF_NEVER , $optderef)); 135 | 136 | // User attribute. 137 | $settings->add(new auth_ldap_admin_setting_special_lowercase_configtext('auth_ldap_syncplus/user_attribute', 138 | get_string('auth_ldap_user_attribute_key', 'auth_ldap'), 139 | get_string('auth_ldap_user_attribute', 'auth_ldap'), '', PARAM_RAW)); 140 | 141 | // Suspended attribute. 142 | $settings->add(new auth_ldap_admin_setting_special_lowercase_configtext('auth_ldap_syncplus/suspended_attribute', 143 | get_string('auth_ldap_suspended_attribute_key', 'auth_ldap'), 144 | get_string('auth_ldap_suspended_attribute', 'auth_ldap'), '', PARAM_RAW)); 145 | 146 | // Member attribute. 147 | $settings->add(new auth_ldap_admin_setting_special_lowercase_configtext('auth_ldap_syncplus/memberattribute', 148 | get_string('auth_ldap_memberattribute_key', 'auth_ldap'), 149 | get_string('auth_ldap_memberattribute', 'auth_ldap'), '', PARAM_RAW)); 150 | 151 | // Member attribute uses dn. 152 | $settings->add(new admin_setting_configselect('auth_ldap_syncplus/memberattribute_isdn', 153 | get_string('auth_ldap_memberattribute_isdn_key', 'auth_ldap'), 154 | get_string('auth_ldap_memberattribute_isdn', 'auth_ldap'), 0, $yesno)); 155 | 156 | // Object class. 157 | $settings->add(new admin_setting_configtext('auth_ldap_syncplus/objectclass', 158 | get_string('auth_ldap_objectclass_key', 'auth_ldap'), 159 | get_string('auth_ldap_objectclass', 'auth_ldap'), '', PARAM_RAW_TRIMMED)); 160 | 161 | // Force Password change Header. 162 | $settings->add(new admin_setting_heading('auth_ldap_syncplus/ldapforcepasswordchange', 163 | new lang_string('forcechangepassword', 'auth'), '')); 164 | 165 | // Force Password change. 166 | $settings->add(new admin_setting_configselect('auth_ldap_syncplus/forcechangepassword', 167 | new lang_string('forcechangepassword', 'auth'), 168 | new lang_string('forcechangepasswordfirst_help', 'auth'), 0 , $yesno)); 169 | 170 | // Standard Password Change. 171 | $settings->add(new admin_setting_configselect('auth_ldap_syncplus/stdchangepassword', 172 | new lang_string('stdchangepassword', 'auth'), new lang_string('stdchangepassword_expl', 'auth') .' '. 173 | get_string('stdchangepassword_explldap', 'auth'), 0 , $yesno)); 174 | 175 | // Password Type. 176 | $passtype = []; 177 | $passtype['plaintext'] = get_string('plaintext', 'auth'); 178 | $passtype['md5'] = get_string('md5', 'auth'); 179 | $passtype['sha1'] = get_string('sha1', 'auth'); 180 | 181 | $settings->add(new admin_setting_configselect('auth_ldap_syncplus/passtype', 182 | new lang_string('auth_ldap_passtype_key', 'auth_ldap'), 183 | new lang_string('auth_ldap_passtype', 'auth_ldap'), 'plaintext', $passtype)); 184 | 185 | // Password change URL. 186 | $settings->add(new admin_setting_configtext('auth_ldap_syncplus/changepasswordurl', 187 | get_string('auth_ldap_changepasswordurl_key', 'auth_ldap'), 188 | get_string('changepasswordhelp', 'auth'), '', PARAM_URL)); 189 | 190 | // Password Expiration Header. 191 | $settings->add(new admin_setting_heading('auth_ldap_syncplus/passwordexpire', 192 | new lang_string('auth_ldap_passwdexpire_settings', 'auth_ldap'), '')); 193 | 194 | // Password Expiration. 195 | 196 | // Create the description lang_string object. 197 | $strno = get_string('no'); 198 | $strldapserver = get_string('pluginname', 'auth_ldap'); 199 | $langobject = new stdClass(); 200 | $langobject->no = $strno; 201 | $langobject->ldapserver = $strldapserver; 202 | $description = new lang_string('auth_ldap_expiration_desc', 'auth_ldap', $langobject); 203 | 204 | // Now create the options. 205 | $expiration = []; 206 | $expiration['0'] = $strno; 207 | $expiration['1'] = $strldapserver; 208 | 209 | // Add the setting. 210 | $settings->add(new admin_setting_configselect('auth_ldap_syncplus/expiration', 211 | new lang_string('auth_ldap_expiration_key', 'auth_ldap'), 212 | $description, 0 , $expiration)); 213 | 214 | // Password Expiration warning. 215 | $settings->add(new admin_setting_configtext('auth_ldap_syncplus/expiration_warning', 216 | get_string('auth_ldap_expiration_warning_key', 'auth_ldap'), 217 | get_string('auth_ldap_expiration_warning_desc', 'auth_ldap'), '', PARAM_RAW)); 218 | 219 | // Password Expiration attribute. 220 | $settings->add(new auth_ldap_admin_setting_special_lowercase_configtext('auth_ldap_syncplus/expireattr', 221 | get_string('auth_ldap_expireattr_key', 'auth_ldap'), 222 | get_string('auth_ldap_expireattr_desc', 'auth_ldap'), '', PARAM_RAW)); 223 | 224 | // Grace Logins. 225 | $settings->add(new admin_setting_configselect('auth_ldap_syncplus/gracelogins', 226 | new lang_string('auth_ldap_gracelogins_key', 'auth_ldap'), 227 | new lang_string('auth_ldap_gracelogins_desc', 'auth_ldap'), 0 , $yesno)); 228 | 229 | // Grace logins attribute. 230 | $settings->add(new auth_ldap_admin_setting_special_lowercase_configtext('auth_ldap_syncplus/graceattr', 231 | get_string('auth_ldap_gracelogin_key', 'auth_ldap'), 232 | get_string('auth_ldap_graceattr_desc', 'auth_ldap'), '', PARAM_RAW)); 233 | 234 | // User Creation. 235 | $settings->add(new admin_setting_heading('auth_ldap_syncplus/usercreation', 236 | new lang_string('auth_user_create', 'auth'), '')); 237 | 238 | // Create users externally. 239 | $settings->add(new admin_setting_configselect('auth_ldap_syncplus/auth_user_create', 240 | new lang_string('auth_ldap_auth_user_create_key', 'auth_ldap'), 241 | new lang_string('auth_user_creation', 'auth'), 0 , $yesno)); 242 | 243 | // Context for new users. 244 | $settings->add(new admin_setting_configtext('auth_ldap_syncplus/create_context', 245 | get_string('auth_ldap_create_context_key', 'auth_ldap'), 246 | get_string('auth_ldap_create_context', 'auth_ldap'), '', PARAM_RAW_TRIMMED)); 247 | 248 | // System roles mapping header. 249 | $settings->add(new admin_setting_heading('auth_ldap_syncplus/systemrolemapping', 250 | new lang_string('systemrolemapping', 'auth_ldap'), '')); 251 | 252 | // Create system role mapping field for each assignable system role. 253 | $roles = get_ldap_assignable_role_names(); 254 | foreach ($roles as $role) { 255 | // Before we can add this setting we need to check a few things. 256 | // A) It does not exceed 100 characters otherwise it will break the DB as the 'name' field 257 | // in the 'config_plugins' table is a varchar(100). 258 | // B) The setting name does not contain hyphens. If it does then it will fail the check 259 | // in parse_setting_name() and everything will explode. Role short names are validated 260 | // against PARAM_ALPHANUMEXT which is similar to the regex used in parse_setting_name() 261 | // except it also allows hyphens. 262 | // Instead of shortening the name and removing/replacing the hyphens we are showing a warning. 263 | // If we were to manipulate the setting name by removing the hyphens we may get conflicts, eg 264 | // 'thisisashortname' and 'this-is-a-short-name'. The same applies for shortening the setting name. 265 | if (core_text::strlen($role['settingname']) > 100 || !preg_match('/^[a-zA-Z0-9_]+$/', $role['settingname'])) { 266 | $url = new \core\url('/admin/roles/define.php', ['action' => 'edit', 'roleid' => $role['id']]); 267 | $a = (object)['rolename' => $role['localname'], 'shortname' => $role['shortname'], 'charlimit' => 93, 268 | 'link' => $url->out(), ]; 269 | $settings->add(new admin_setting_heading('auth_ldap_syncplus/role_not_mapped_' . sha1($role['settingname']), '', 270 | get_string('cannotmaprole', 'auth_ldap', $a))); 271 | } else { 272 | $settings->add(new admin_setting_configtext('auth_ldap_syncplus/' . $role['settingname'], 273 | get_string('auth_ldap_rolecontext', 'auth_ldap', $role), 274 | get_string('auth_ldap_rolecontext_help', 'auth_ldap', $role), '', PARAM_RAW_TRIMMED)); 275 | } 276 | } 277 | 278 | // User Account Sync. 279 | $settings->add(new admin_setting_heading('auth_ldap_syncplus/syncusers', 280 | new lang_string('auth_sync_script', 'auth'), '')); 281 | 282 | // Remove external user. 283 | $deleteopt = []; 284 | $deleteopt[AUTH_REMOVEUSER_KEEP] = get_string('auth_remove_keep', 'auth'); 285 | $deleteopt[AUTH_REMOVEUSER_SUSPEND] = get_string('auth_remove_suspend', 'auth'); 286 | $deleteopt[AUTH_REMOVEUSER_FULLDELETE] = get_string('auth_remove_delete', 'auth'); 287 | $deleteopt[AUTH_REMOVEUSER_DELETEWITHGRACEPERIOD] = get_string('auth_remove_deletewithgraceperiod', 'auth_ldap_syncplus'); 288 | 289 | $settings->add(new admin_setting_configselect('auth_ldap_syncplus/removeuser', 290 | new lang_string('auth_remove_user_key', 'auth'), 291 | new lang_string('auth_remove_user', 'auth'), AUTH_REMOVEUSER_KEEP, $deleteopt)); 292 | 293 | // Remove external user grace period. 294 | $settings->add(new admin_setting_configtext('auth_ldap_syncplus/removeuser_graceperiod', 295 | new lang_string('removeuser_graceperiod', 'auth_ldap_syncplus'), 296 | new lang_string('removeuser_graceperiod_desc', 'auth_ldap_syncplus'), 10, PARAM_INT)); 297 | 298 | // Create users. 299 | $settings->add(new admin_setting_configselect('auth_ldap_syncplus/sync_script_createuser_enabled', 300 | new lang_string('sync_script_createuser_enabled_key', 'auth_ldap_syncplus'), 301 | new lang_string('sync_script_createuser_enabled', 'auth_ldap_syncplus'), 1, $yesno)); 302 | 303 | // Sync Suspension. 304 | $settings->add(new admin_setting_configselect('auth_ldap_syncplus/sync_suspended', 305 | new lang_string('auth_sync_suspended_key', 'auth'), 306 | new lang_string('auth_sync_suspended', 'auth'), 0 , $yesno)); 307 | 308 | // Sync update users chunk size. 309 | $settings->add(new admin_setting_configtext('auth_ldap_syncplus/sync_updateuserchunk', 310 | new lang_string('sync_updateuserchunk_key', 'auth_ldap'), 311 | new lang_string('sync_updateuserchunk', 'auth_ldap'), 1000, PARAM_INT)); 312 | 313 | // NTLM SSO Header. 314 | $settings->add(new admin_setting_heading('auth_ldap_syncplus/ntlm', 315 | new lang_string('auth_ntlmsso', 'auth_ldap'), '')); 316 | 317 | // Enable NTLM. 318 | $settings->add(new admin_setting_configselect('auth_ldap_syncplus/ntlmsso_enabled', 319 | new lang_string('auth_ntlmsso_enabled_key', 'auth_ldap'), 320 | new lang_string('auth_ntlmsso_enabled', 'auth_ldap'), 0 , $yesno)); 321 | 322 | // Subnet. 323 | $settings->add(new admin_setting_configtext('auth_ldap_syncplus/ntlmsso_subnet', 324 | get_string('auth_ntlmsso_subnet_key', 'auth_ldap'), 325 | get_string('auth_ntlmsso_subnet', 'auth_ldap'), '', PARAM_RAW_TRIMMED)); 326 | 327 | // NTLM Fast Path. 328 | $fastpathoptions = []; 329 | $fastpathoptions[AUTH_NTLM_FASTPATH_YESFORM] = get_string('auth_ntlmsso_ie_fastpath_yesform', 'auth_ldap'); 330 | $fastpathoptions[AUTH_NTLM_FASTPATH_YESATTEMPT] = get_string('auth_ntlmsso_ie_fastpath_yesattempt', 'auth_ldap'); 331 | $fastpathoptions[AUTH_NTLM_FASTPATH_ATTEMPT] = get_string('auth_ntlmsso_ie_fastpath_attempt', 'auth_ldap'); 332 | 333 | $settings->add(new admin_setting_configselect('auth_ldap_syncplus/ntlmsso_ie_fastpath', 334 | new lang_string('auth_ntlmsso_ie_fastpath_key', 'auth_ldap'), 335 | new lang_string('auth_ntlmsso_ie_fastpath', 'auth_ldap'), 336 | AUTH_NTLM_FASTPATH_ATTEMPT, $fastpathoptions)); 337 | 338 | // Authentication type. 339 | $types = []; 340 | $types['ntlm'] = 'NTLM'; 341 | $types['kerberos'] = 'Kerberos'; 342 | 343 | $settings->add(new admin_setting_configselect('auth_ldap_syncplus/ntlmsso_type', 344 | new lang_string('auth_ntlmsso_type_key', 'auth_ldap'), 345 | new lang_string('auth_ntlmsso_type', 'auth_ldap'), 'ntlm', $types)); 346 | 347 | // Remote Username format. 348 | $settings->add(new auth_ldap_admin_setting_special_ntlm_configtext('auth_ldap_syncplus/ntlmsso_remoteuserformat', 349 | get_string('auth_ntlmsso_remoteuserformat_key', 'auth_ldap'), 350 | get_string('auth_ntlmsso_remoteuserformat', 'auth_ldap'), '', PARAM_RAW_TRIMMED)); 351 | } 352 | 353 | // Display locking / mapping of profile fields. 354 | $authplugin = get_auth_plugin('ldap_syncplus'); 355 | $help = get_string('auth_ldapextrafields', 'auth_ldap'); 356 | $help .= get_string('auth_updatelocal_expl', 'auth'); 357 | $help .= get_string('auth_fieldlock_expl', 'auth'); 358 | $help .= get_string('auth_updateremote_expl', 'auth'); 359 | $help .= '
'; 360 | $help .= get_string('auth_updateremote_ldap', 'auth'); 361 | display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields, 362 | $help, true, true, $authplugin->get_custom_user_profile_fields()); 363 | } 364 | -------------------------------------------------------------------------------- /tests/behat/auth_ldap_syncplus.feature: -------------------------------------------------------------------------------- 1 | @auth @auth_ldap_syncplus 2 | Feature: Checking that all LDAP (Sync Plus) specific settings are working 3 | In order to be able to use the auth_ldap_syncplus plugin properly 4 | As admin 5 | I need to be sure that LDAP (Sync Plus) provides working additional features over the LDAP plugin from Moodle core. 6 | 7 | Background: 8 | Given the following config values are set as admin: 9 | | config | value | 10 | | auth | manual,ldap_syncplus | 11 | | authpreventaccountcreation | 0 | 12 | And the following config values are set as admin: 13 | | config | value | plugin | 14 | | host_url | ldap://localhost:1389 | auth_ldap_syncplus | 15 | | start_tls | 0 | auth_ldap_syncplus | 16 | | bind_dn | cn=admin,dc=example,dc=org | auth_ldap_syncplus | 17 | | bind_pw | adminpassword | auth_ldap_syncplus | 18 | | contexts | ou=department,dc=example,dc=org | auth_ldap_syncplus | 19 | | user_attribute | uid | auth_ldap_syncplus | 20 | | field_map_firstname | givenName | auth_ldap_syncplus | 21 | | field_updatelocal_firstname | onlogin | auth_ldap_syncplus | 22 | | field_map_lastname | sn | auth_ldap_syncplus | 23 | | field_updatelocal_lastname | onlogin | auth_ldap_syncplus | 24 | | field_map_email | mail | auth_ldap_syncplus | 25 | | field_updatelocal_email | onlogin | auth_ldap_syncplus | 26 | 27 | Scenario: All additional LDAP server (Sync Plus) settings should be there 28 | When I log in as "admin" 29 | And I navigate to "Plugins > Authentication > Manage authentication" in site administration 30 | And I click on "Settings" "link" in the "LDAP server (Sync Plus)" "table_row" 31 | Then I should see "LDAP server (Sync Plus)" in the "#region-main .settingsform" "css_element" 32 | And the "Removed ext user" select box should contain "Suspend internal and fully delete internal after grace period" 33 | And I should see "Fully deleting grace period" in the "#admin-removeuser_graceperiod" "css_element" 34 | And I should see "Add new users" in the "#admin-sync_script_createuser_enabled" "css_element" 35 | 36 | Scenario: The LDAP connection should work 37 | When I log in as "admin" 38 | And I navigate to "Plugins > Authentication > Manage authentication" in site administration 39 | And I click on "Test settings" "link" in the "LDAP server (Sync Plus)" "table_row" 40 | And I should see "Connecting to your LDAP server was successful" 41 | 42 | Scenario: The LDAP synchronization task should suspend users who have disappeared in LDAP and delete them after a configurable grace period 43 | Given the following config values are set as admin: 44 | | config | value | plugin | 45 | | removeuser | 3 | auth_ldap_syncplus | 46 | | removeuser_graceperiod | 2 | auth_ldap_syncplus | 47 | # user01 exists in the LDAP server, user03 does not. 48 | And the following "users" exist: 49 | | username | firstname | lastname | email | auth | 50 | | user01 | User | 01 | user01@example.com | ldap_syncplus | 51 | | user03 | User | 03 | user03@example.com | ldap_syncplus | 52 | When I log in as "admin" 53 | And I navigate to "Users > Accounts > Browse list of users" in site administration 54 | And I should see "User 01" in the "[data-region='report-user-list-wrapper']" "css_element" 55 | And I should see "User 03" in the "[data-region='report-user-list-wrapper']" "css_element" 56 | And I should not see "Suspended" in the "User 01" "table_row" 57 | And I should not see "Suspended" in the "User 03" "table_row" 58 | And I run the scheduled task "\auth_ldap_syncplus\task\sync_task" 59 | And I reload the page 60 | Then I should see "User 01" in the "[data-region='report-user-list-wrapper']" "css_element" 61 | And I should see "User 03" in the "[data-region='report-user-list-wrapper']" "css_element" 62 | And I should not see "Suspended" in the "User 01" "table_row" 63 | And I should see "Suspended" in the "User 03" "table_row" 64 | And I pretend the suspended user "user03" was suspended "3" days ago 65 | And I run the scheduled task "\auth_ldap_syncplus\task\sync_task" 66 | And I reload the page 67 | Then I should see "User 01" in the "[data-region='report-user-list-wrapper']" "css_element" 68 | And I should not see "User 03" in the "[data-region='report-user-list-wrapper']" "css_element" 69 | And I should not see "Suspended" in the "User 01" "table_row" 70 | 71 | Scenario: The LDAP synchronization task should revive suspended users who have re-appeared in LDAP within the grace period 72 | Given the following config values are set as admin: 73 | | config | value | plugin | 74 | | removeuser | 3 | auth_ldap_syncplus | 75 | | removeuser_graceperiod | 2 | auth_ldap_syncplus | 76 | And the following "users" exist: 77 | # user01 and user02 exist in the LDAP server. 78 | | username | firstname | lastname | email | auth | 79 | | user01 | User | 01 | user01@example.com | ldap_syncplus | 80 | | user02 | User | 02 | user02@example.com | ldap_syncplus | 81 | When I log in as "admin" 82 | And I pretend the suspended user "user02" was suspended "1" days ago 83 | And I navigate to "Users > Accounts > Browse list of users" in site administration 84 | And I should see "User 01" in the "[data-region='report-user-list-wrapper']" "css_element" 85 | And I should see "User 02" in the "[data-region='report-user-list-wrapper']" "css_element" 86 | And I should not see "Suspended" in the "User 01" "table_row" 87 | And I should see "Suspended" in the "User 02" "table_row" 88 | And I run the scheduled task "\auth_ldap_syncplus\task\sync_task" 89 | And I reload the page 90 | Then I should see "User 01" in the "[data-region='report-user-list-wrapper']" "css_element" 91 | And I should see "User 02" in the "[data-region='report-user-list-wrapper']" "css_element" 92 | And I should not see "Suspended" in the "User 01" "table_row" 93 | And I should not see "Suspended" in the "User 02" "table_row" 94 | 95 | Scenario: The LDAP synchronization task should suspend users who have disappeared in LDAP (Countercheck / Moodle core behaviour) 96 | Given the following config values are set as admin: 97 | | config | value | plugin | 98 | | removeuser | 1 | auth_ldap_syncplus | 99 | # user01 exists in the LDAP server, user03 does not. 100 | And the following "users" exist: 101 | | username | firstname | lastname | email | auth | 102 | | user01 | User | 01 | user01@example.com | ldap_syncplus | 103 | | user03 | User | 03 | user03@example.com | ldap_syncplus | 104 | When I log in as "admin" 105 | And I navigate to "Users > Accounts > Browse list of users" in site administration 106 | And I should see "User 01" in the "[data-region='report-user-list-wrapper']" "css_element" 107 | And I should see "User 03" in the "[data-region='report-user-list-wrapper']" "css_element" 108 | And I should not see "Suspended" in the "User 01" "table_row" 109 | And I should not see "Suspended" in the "User 03" "table_row" 110 | And I run the scheduled task "\auth_ldap_syncplus\task\sync_task" 111 | And I reload the page 112 | Then I should see "User 01" in the "[data-region='report-user-list-wrapper']" "css_element" 113 | And I should see "User 03" in the "[data-region='report-user-list-wrapper']" "css_element" 114 | And I should not see "Suspended" in the "User 01" "table_row" 115 | And I should see "Suspended" in the "User 03" "table_row" 116 | 117 | Scenario: The LDAP synchronization task should revive suspended users who have re-appeared in LDAP after they have been suspended 118 | Given the following config values are set as admin: 119 | | config | value | plugin | 120 | | removeuser | 1 | auth_ldap_syncplus | 121 | And the following "users" exist: 122 | # user01 and user02 exist in the LDAP server. 123 | | username | firstname | lastname | email | auth | 124 | | user01 | User | 01 | user01@example.com | ldap_syncplus | 125 | | user02 | User | 02 | user02@example.com | ldap_syncplus | 126 | When I log in as "admin" 127 | And I pretend the suspended user "user02" was suspended "1" days ago 128 | And I navigate to "Users > Accounts > Browse list of users" in site administration 129 | And I should see "User 01" in the "[data-region='report-user-list-wrapper']" "css_element" 130 | And I should see "User 02" in the "[data-region='report-user-list-wrapper']" "css_element" 131 | And I should not see "Suspended" in the "User 01" "table_row" 132 | And I should see "Suspended" in the "User 02" "table_row" 133 | And I run the scheduled task "\auth_ldap_syncplus\task\sync_task" 134 | And I reload the page 135 | Then I should see "User 01" in the "[data-region='report-user-list-wrapper']" "css_element" 136 | And I should see "User 02" in the "[data-region='report-user-list-wrapper']" "css_element" 137 | And I should not see "Suspended" in the "User 01" "table_row" 138 | And I should not see "Suspended" in the "User 02" "table_row" 139 | 140 | Scenario: The LDAP synchronization task should delete users who have disappeared in LDAP (Countercheck / Moodle core behaviour) 141 | Given the following config values are set as admin: 142 | | config | value | plugin | 143 | | removeuser | 2 | auth_ldap_syncplus | 144 | # user01 exists in the LDAP server, user03 does not. 145 | And the following "users" exist: 146 | | username | firstname | lastname | email | auth | 147 | | user01 | User | 01 | user01@example.com | ldap_syncplus | 148 | | user03 | User | 03 | user03@example.com | ldap_syncplus | 149 | When I log in as "admin" 150 | And I navigate to "Users > Accounts > Browse list of users" in site administration 151 | And I should see "User 01" in the "[data-region='report-user-list-wrapper']" "css_element" 152 | And I should see "User 03" in the "[data-region='report-user-list-wrapper']" "css_element" 153 | And I should not see "Suspended" in the "User 01" "table_row" 154 | And I should not see "Suspended" in the "User 03" "table_row" 155 | And I run the scheduled task "\auth_ldap_syncplus\task\sync_task" 156 | And I reload the page 157 | Then I should see "User 01" in the "[data-region='report-user-list-wrapper']" "css_element" 158 | And I should not see "User 03" in the "[data-region='report-user-list-wrapper']" "css_element" 159 | And I should not see "Suspended" in the "User 01" "table_row" 160 | 161 | Scenario: The LDAP synchronization task should not create Moodle accounts for all LDAP users 162 | Given the following config values are set as admin: 163 | | config | value | plugin | 164 | | sync_script_createuser_enabled | 0 | auth_ldap_syncplus | 165 | When I log in as "admin" 166 | And I navigate to "Users > Accounts > Browse list of users" in site administration 167 | And I should not see "User 01" in the "[data-region='report-user-list-wrapper']" "css_element" 168 | And I run the scheduled task "\auth_ldap_syncplus\task\sync_task" 169 | And I reload the page 170 | Then I should not see "User 01" in the "[data-region='report-user-list-wrapper']" "css_element" 171 | 172 | Scenario: The LDAP synchronization task should create Moodle accounts for all LDAP users (Countercheck / Moodle core behaviour) 173 | Given the following config values are set as admin: 174 | | config | value | plugin | 175 | | sync_script_createuser_enabled | 1 | auth_ldap_syncplus | 176 | When I log in as "admin" 177 | And I navigate to "Users > Accounts > Browse list of users" in site administration 178 | And I should not see "User 01" in the "[data-region='report-user-list-wrapper']" "css_element" 179 | And I run the scheduled task "\auth_ldap_syncplus\task\sync_task" 180 | And I reload the page 181 | Then I should see "User 01" in the "[data-region='report-user-list-wrapper']" "css_element" 182 | 183 | Scenario: On manual user creation, user details should be fetched from LDAP 184 | When I log in as "admin" 185 | And I navigate to "Users > Accounts > Add a new user" in site administration 186 | And I set the following fields to these values: 187 | | Username | user01 | 188 | | Choose an authentication method | ldap_syncplus | 189 | | First name | Foo | 190 | | Last name | Bar | 191 | | Email address | foo@bar.com | 192 | | New password | Hello!123 | 193 | And I press "Create user" 194 | And I navigate to "Users > Accounts > Browse list of users" in site administration 195 | Then I should see "User 01" in the "[data-region='report-user-list-wrapper']" "css_element" 196 | And I click on "Edit" "link" in the "User 01" "table_row" 197 | And the field "Username" matches value "user01" 198 | And the field "First name" matches value "User" 199 | And the field "Last name" matches value "01" 200 | And the field "Email address" matches value "user01@example.com" 201 | 202 | Scenario: First login via email should be possible without an existing Moodle account 203 | Given the following config values are set as admin: 204 | | config | value | 205 | | authloginviaemail | 1 | 206 | When I follow "Log in" 207 | And I set the field "Username" to "user01@example.com" 208 | And I set the field "Password" to "password1" 209 | And I press "Log in" 210 | Then I should see "Welcome, User" 211 | And I should not see "Invalid login" 212 | 213 | Scenario: First login via username should be possible without an existing Moodle account (Countercheck / Moodle core behaviour) 214 | When I follow "Log in" 215 | And I set the field "Username" to "user01" 216 | And I set the field "Password" to "password1" 217 | And I press "Log in" 218 | Then I should see "Welcome, User" 219 | And I should not see "Invalid login" 220 | 221 | Scenario: Update user profile fields from LDAP (Moodle core behaviour) 222 | Given the following "users" exist: 223 | # user01 exists in the LDAP server. 224 | | username | firstname | lastname | email | auth | 225 | | user01 | User | 01 | user01@example.com | ldap_syncplus | 226 | When I log in as "admin" 227 | And I navigate to "Users > Accounts > Browse list of users" in site administration 228 | And I should see "User 01" in the "[data-region='report-user-list-wrapper']" "css_element" 229 | And I should not see "Foo Bar" in the "[data-region='report-user-list-wrapper']" "css_element" 230 | And I click on "Edit" "link" in the "User 01" "table_row" 231 | And I set the following fields to these values: 232 | | First name | Foo | 233 | | Last name | Bar | 234 | | Email address | foo@bar.com | 235 | And I press "Update profile" 236 | And I navigate to "Users > Accounts > Browse list of users" in site administration 237 | And I should not see "User 01" in the "[data-region='report-user-list-wrapper']" "css_element" 238 | And I should see "Foo Bar" in the "[data-region='report-user-list-wrapper']" "css_element" 239 | And I run the scheduled task "\auth_ldap_syncplus\task\sync_task" 240 | And I run all adhoc tasks 241 | And I reload the page 242 | Then I should see "User 01" in the "[data-region='report-user-list-wrapper']" "css_element" 243 | And I should not see "Foo Bar" in the "[data-region='report-user-list-wrapper']" "css_element" 244 | And I click on "Edit" "link" in the "User 01" "table_row" 245 | And the field "Username" matches value "user01" 246 | And the field "First name" matches value "User" 247 | And the field "Last name" matches value "01" 248 | And the field "Email address" matches value "user01@example.com" 249 | -------------------------------------------------------------------------------- /tests/behat/behat_auth_ldap_syncplus.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Auth plugin "LDAP SyncPlus" - Steps definitions 19 | * 20 | * @package auth_ldap_syncplus 21 | * @copyright 2022 Alexander Bias 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | 25 | // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. 26 | 27 | require_once(__DIR__ . '/../../../../lib/behat/behat_base.php'); 28 | 29 | /** 30 | * Step definitions. 31 | * 32 | * @package auth_ldap_syncplus 33 | * @copyright 2022 Alexander Bias 34 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 | */ 36 | class behat_auth_ldap_syncplus extends behat_base { 37 | 38 | /** 39 | * The step makes sure that a given user appears to be suspended already some days ago to test the grace period setting 40 | * of this plugin. 41 | * 42 | * @When /^I pretend the suspended user "(?P(?:[^"]|\\")*)" was suspended "(?P\d+)" days ago/ 43 | * @param string $username 44 | * @param int $days 45 | * @return void 46 | */ 47 | public function i_pretend_that_the_suspended_user_was_already_suspended_days_ago($username, $days) { 48 | global $DB; 49 | 50 | // Get the user record of the given user. 51 | $user = $DB->get_record('user', ['username' => $username]); 52 | 53 | // Update the suspended field in the user record. 54 | $user->suspended = 1; 55 | 56 | // Update the timemodified field in the user record. 57 | $user->timemodified = time() - $days * DAYSECS; 58 | 59 | // Update the user record in the database. 60 | $DB->update_record('user', $user); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /tests/fixtures/bitnami-openldap-docker-compose.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | openldap: 3 | image: docker.io/bitnami/openldap:2.6 4 | ports: 5 | - '1389:1389' 6 | - '1636:1636' 7 | environment: 8 | - BITNAMI_DEBUG=true 9 | - LDAP_ADMIN_USERNAME=admin 10 | - LDAP_ADMIN_PASSWORD=adminpassword 11 | volumes: 12 | - 'openldap_data:/bitnami/openldap' 13 | - ./ldifs:/ldifs/ 14 | 15 | volumes: 16 | openldap_data: 17 | driver: local 18 | -------------------------------------------------------------------------------- /tests/fixtures/ldifs/auth_ldap_syncplus.ldif: -------------------------------------------------------------------------------- 1 | # Root creation 2 | dn: dc=example,dc=org 3 | objectClass: dcObject 4 | objectClass: organization 5 | dc: example 6 | o: org 7 | 8 | # Organizational Unit 9 | dn: ou=department,dc=example,dc=org 10 | objectClass: organizationalUnit 11 | ou: department 12 | 13 | # user01 entry 14 | dn: uid=user01,ou=department,dc=example,dc=org 15 | uid: user01 16 | cn: User 01 17 | givenName: User 18 | sn: 01 19 | mail: user01@example.com 20 | userPassword: password1 21 | objectClass: InetOrgPerson 22 | 23 | # user02 entry 24 | dn: uid=user02,ou=department,dc=example,dc=org 25 | uid: user02 26 | cn: User 02 27 | givenName: User 28 | sn: 02 29 | mail: user02@example.com 30 | userPassword: password2 31 | objectClass: InetOrgPerson 32 | -------------------------------------------------------------------------------- /version.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | /** 18 | * Auth plugin "LDAP SyncPlus" - Version file 19 | * 20 | * @package auth_ldap_syncplus 21 | * @copyright 2014 Alexander Bias, Ulm University 22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 | */ 24 | 25 | defined('MOODLE_INTERNAL') || die(); 26 | 27 | $plugin->component = 'auth_ldap_syncplus'; 28 | $plugin->version = 2025041400; 29 | $plugin->release = 'v5.0-r1'; 30 | $plugin->requires = 2025041400; 31 | $plugin->supported = [500, 500]; 32 | $plugin->maturity = MATURITY_STABLE; 33 | $plugin->dependencies = ['auth_ldap' => 2025041400]; 34 | --------------------------------------------------------------------------------