Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change useOpenLdap.js to case-insensitive attribute name indices #8366

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,45 @@ import {
function useOpenLdap(form) {

const performSearch = (filter, scope, attributes, base_dn) => {
return sendLdapSearchRequest({...form.value}, filter, scope, attributes, base_dn)
return sendLdapSearchRequest({...form.value}, filter, scope, attributes, base_dn, 1000)
.then((result) => {
return {results: parseLdapResponseToAttributeArray(result, extractAttributeFromFilter(filter)), success: true}
}
)
}

const getSubSchemaDN = () => {
return sendLdapSearchRequest({...form.value}, null, 'base', ['subSchemaSubEntry'], form.value.basedn)
return sendLdapSearchRequest({...form.value}, null, 'base', ['subSchemaSubEntry'], '', 1)
.then((response) => {
let firstAttribute = response[Object.keys(response)[0]]
return firstAttribute['subschemaSubentry']
const keys = Object.keys(response)
if (keys.length) {
const firstAttribute = response[keys[0]]
const lowerCaseKeys = Object.keys(firstAttribute).map(key => key.toLowerCase())
const subSchemaSubEntryIndex = lowerCaseKeys.indexOf('subschemasubentry')
if (subSchemaSubEntryIndex !== -1) {
const subSchemaSubEntryKey = Object.keys(firstAttribute)[subSchemaSubEntryIndex]
return firstAttribute[subSchemaSubEntryKey]
}
}
return []
})
}

const fetchAttributeTypes = (subSchemaDN) => {
return sendLdapSearchRequest({...form.value}, '(objectclass=subschema)',
'base',
['attributeTypes'],
subSchemaDN)
return sendLdapSearchRequest({...form.value}, '(objectClass=subSchema)', 'base', ['attributeTypes'], subSchemaDN, 1000)
.then((response) => {
const keys = Object.keys(response)
if (keys.length) {
const { attributeTypes } = response[keys[0]]
return attributeTypes
const firstAttribute = response[keys[0]]
const lowerCaseKeys = Object.keys(firstAttribute).map(key => key.toLowerCase())
const attributeTypesIndex = lowerCaseKeys.indexOf('attributetypes')
if (attributeTypesIndex !== -1) {
const attributeTypesKey = Object.keys(firstAttribute)[attributeTypesIndex]
return firstAttribute[attributeTypesKey]
}
}
return []
})
})
}

const getAttributes = () => {
Expand Down