<commit_before>const request = require('request-promise-native');

const AbstractLDAPStrategy = require('./interface.js');

/**
 * General LDAP functionality
 * @implements {AbstractLDAPStrategy}
 */
class GeneralLDAPStrategy extends AbstractLDAPStrategy {
	constructor(app, config) {
		super(app, config);
	}

	/**
     * @public
     * @see AbstractLDAPStrategy#getSchoolsQuery
     * @returns {Array} Array of Objects containing ldapOu (ldap Organization Path), displayName
     * @memberof GeneralLDAPStrategy
     */
	getSchools() {
		return Promise.resolve([{
			displayName: this.config.providerOptions.schoolName,
			ldapOu: this.config.rootPath,
		}]);
	}

	/**
     * @public
     * @see AbstractLDAPStrategy#getUsers
     * @returns {Array} Array of Objects containing email, firstName, lastName, ldapDn, ldapUUID, ldapUID,
     * (Array) roles = ['teacher', 'student', 'administrator']
     * @memberof GeneralLDAPStrategy
     */
	getUsers(school) {
		const {
			userAttributeNameMapping,
			userPathAdditions,
			roleType,
			roleAttributeNameMapping,
		} = this.config.providerOptions;

		const options = {
			filter: 'objectClass=person',
			scope: 'sub',
			attributes: [<commit_msg>Require uuid and email attribute<commit_after>const request = require('request-promise-native');

const AbstractLDAPStrategy = require('./interface.js');

/**
 * General LDAP functionality
 * @implements {AbstractLDAPStrategy}
 */
class GeneralLDAPStrategy extends AbstractLDAPStrategy {
	constructor(app, config) {
		super(app, config);
	}

	/**
     * @public
     * @see AbstractLDAPStrategy#getSchoolsQuery
     * @returns {Array} Array of Objects containing ldapOu (ldap Organization Path), displayName
     * @memberof GeneralLDAPStrategy
     */
	getSchools() {
		return Promise.resolve([{
			displayName: this.config.providerOptions.schoolName,
			ldapOu: this.config.rootPath,
		}]);
	}

	/**
     * @public
     * @see AbstractLDAPStrategy#getUsers
     * @returns {Array} Array of Objects containing email, firstName, lastName, ldapDn, ldapUUID, ldapUID,
     * (Array) roles = ['teacher', 'student', 'administrator']
     * @memberof GeneralLDAPStrategy
     */
	getUsers(school) {
		const {
			userAttributeNameMapping,
			userPathAdditions,
			roleType,
			roleAttributeNameMapping,
		} = this.config.providerOptions;

		const requiredAttributes = [
			userAttributeNameMapping.uuid,
			userAttributeNameMapping.mail,
		];
		const requiredFilters = requiredAttributes.map((attr) => `(${attr}=*)`).join('');
		const filter = `(&(objectClass=person)${requiredFilters})`;

		const options = {
			filter,
			scope: 'sub',
			attributes: [
{'fraction_non_alphanumeric': 0.12235649546827794, 'fraction_numerical': 0.0, 'mean_word_length': 4.133720930232558, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1069424', 'n_tokens_mistral': 858, 'n_tokens_neox': 794, 'n_words': 170}