Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getLocation(id) {
const params = {
url: config.ldapBaseUrl,
base: `ou=${this.state.scope.ou},o=${config.organization}`,
scope: 'sub',
filter: `(${config.scopes.locations.attributes.id}=${id})`,
};
const options = { method: 'GET', headers };
const query = buildQuery(params);
fetch(`/ldap/${query}`, options)
.then(processStatus)
.then(response => response.json())
.then(result => this.setState({ location: result[0], error: undefined }))
.catch(error => this.setState({ location: {}, error }));
}
getGroups(props) {
this.setState({ groups: [], busy: true });
if (props.person.dn) {
this.setState({ busy: true });
const filter =
`(&(objectClass=${config.scopes.groups.attributes.objectClass})` +
`(member=${props.person.dn}))`;
const params = {
url: config.ldapBaseUrl,
base: `ou=${this.state.scope.ou},o=${config.organization}`,
scope: 'sub',
filter,
attributes: attributesToArray(this.state.scope.attributes),
};
const options = { method: 'GET', headers };
const query = buildQuery(params);
fetch(`/ldap/${query}`, options)
.then(processStatus)
.then(response => response.json())
.then(this.onGroupsResponse)
.catch(error => this.setState({ groups: [], error, busy: false }));
}
}
getGroup(id) {
const params = {
url: config.ldapBaseUrl,
base: `ou=${this.state.scope.ou},o=${config.organization}`,
scope: 'sub',
filter: `(${config.scopes.groups.attributes.id}=${id})`,
};
const options = { method: 'GET', headers };
const query = buildQuery(params);
fetch(`/ldap/${query}`, options)
.then(processStatus)
.then(response => response.json())
.then(this.onGroupResponse)
.catch(error => this.setState({ group: {}, error }));
}
getManager(managerDn) {
const params = {
url: config.ldapBaseUrl,
base: managerDn,
scope: 'sub',
};
const options = { method: 'GET', headers };
const query = buildQuery(params);
fetch(`/ldap/${query}`, options)
.then(processStatus)
.then(response => response.json())
.then(this.onManagerResponse)
.catch(error => this.setState({ staff: [], error }));
}
export function watchAggregate (name, params, successHandler, errorHandler) {
stopWatching(name, true);
const query = buildQuery(params);
const uri = `/rest/index/resources/aggregated${query}`;
const watcher = watch(uri,
(result) => normalizeAggregate(result, successHandler),
errorHandler);
watches[name] = watcher;
}
getPerson(id) {
const params = {
url: config.ldapBaseUrl,
base: `ou=${this.state.scope.ou},o=${config.organization}`,
scope: 'sub',
filter: `(${config.scopes.people.attributes.id}=${id})`,
};
const options = { method: 'GET', headers };
const query = buildQuery(params);
fetch(`/ldap/${query}`, options)
.then(processStatus)
.then(response => response.json())
.then(this.onPersonResponse)
.catch(error => this.setState({ person: {}, error }));
}
getAssistant(assistantDn) {
const params = {
url: config.ldapBaseUrl,
base: assistantDn,
scope: 'sub',
};
const options = { method: 'GET', headers };
const query = buildQuery(params);
fetch(`/ldap/${query}`, options)
.then(processStatus)
.then(response => response.json())
.then(result => this.setState({ assistant: result[0], error: undefined }))
.catch(error => this.setState({ assistant: {}, error }));
}