public final class LdapUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
addGroupMember(LdapService ldapSvc,
String uid,
String groupCn)
A light-weight method to add a member to a
groupOfNames without reading the whole
thing in first. |
static boolean |
addGroupOwner(LdapService ldapSvc,
String uid,
String groupCn)
A light-weight method to add an owner to a
groupOfNames without reading the whole
thing in first. |
static boolean |
addPosixGroupMember(LdapService ldapSvc,
String uid,
String groupCn)
A light-weight method to add a member to a
posixGroup without reading the whole
thing in first. |
static List<String> |
dnsToUids(List<String> dns)
Converts a list of Distinguished Names to a list of uids.
|
static String |
dnToUid(String dn)
Converts a Distinguished Name for a person to the uid for that person.
|
static boolean |
isGroupMember(LdapService ldapSvc,
String groupCn,
String userUid)
Tests to see if a particular user is a member of a particular LDAP
groupOfNames. |
static boolean |
isGroupOwner(LdapService ldapSvc,
String groupCn,
String userUid)
Tests to see if a particular user is an owner of a particular LDAP
groupOfNames. |
static String |
personIdToUid(LdapService ldapSvc,
int personId)
Converts a PersonId to a uid by querying the LDAP.
|
static List<String> |
processExternalPhones(String rawField)
Turns the String stored in any of the phone number-related properties
of beans into a List of numbers suitable for external display.
|
static List<String> |
processInternalPhones(String rawField)
Turns the String stored in any of the phone number-related properties
of beans into a List of numbers suitable for internal display.
|
static boolean |
removeGroupMember(LdapService ldapSvc,
String uid,
String groupCn)
A light-weight method to remove a member from a
groupOfNames without reading the
whole thing in first. |
static boolean |
removeGroupOwner(LdapService ldapSvc,
String uid,
String groupCn)
A light-weight method to remove an owner from a
groupOfNames without reading the
whole thing in first. |
static boolean |
removePosixGroupMember(LdapService ldapSvc,
String uid,
String groupCn)
A light-weight method to remove a member from a
posixGroup without reading the
whole thing in first. |
static List<GroupRecord> |
searchGroupRecords(LdapService ldapSvc,
String filter)
Searches for groups (
groupOfNames or posixGroup) using the supplied filter,
and returns a fully-fledged GroupRecord object for each one found. |
static List<GroupRecord> |
searchGroupRecords(LdapService ldapSvc,
String filter,
int searchScope)
Searches for groups (
groupOfNames or posixGroup) using the supplied filter
and search scope, and returns a fully-fledged GroupRecord object for each one found. |
static List<PersonRecord> |
searchPersonRecords(LdapService ldapSvc,
String filter)
Searches for people using the supplied filter, and returns a fully-fledged
PersonRecord object for each one found.
|
static Map<RoleRecord,PersonRecord> |
searchRoleRecords(LdapService ldapSvc,
String filter)
Searches for roles using the supplied filter and returns a RoleRecord object,
along with the fully-fledged PersonRecord object containing it, for each one
found.
|
static List<UnitRecord> |
searchUnitRecords(LdapService ldapSvc,
String filter)
Searches for units using the supplied filter, and returns a fully-fledged
UnitRecord object for each one found.
|
static List<String> |
uidsToDns(List<String> uids)
Converts a list of uids to a list of Distinguished Names.
|
static String |
uidToDn(String uid)
Converts a uid to a Distinguished Name for the object representing that uid.
|
static int |
uidToPersonId(LdapService ldapSvc,
String uid)
Converts a uid to a PersonId by querying the LDAP.
|
static boolean |
usernameExists(LdapService ldapSvc,
String uid)
Queries the LDAP to check if a username exists.
|
public static String uidToDn(String uid)
uid - The uid to convertpublic static List<String> uidsToDns(List<String> uids)
uids - The list of uids to convertpublic static String dnToUid(String dn) throws NamingException
dn - The DN to convertNamingException - if the format of the DN isn't correctpublic static List<String> dnsToUids(List<String> dns) throws NamingException
dns - The list of DNs to convertNamingException - if the format of a DN is incorrectpublic static boolean usernameExists(LdapService ldapSvc, String uid) throws NamingException
ldapSvc - an LdapService configured to connect to the relevant serveruid - the username to checktrue if the username exists on the serverNamingException - in case of LDAP errorpublic static String personIdToUid(LdapService ldapSvc, int personId) throws NamingException, NotFoundException
ldapSvc - an LdapService configured to connect to the relevant serverpersonId - the PersonId to convert to a uidNamingException - in case of LDAP errorNotFoundException - if the uid cannot be locatedpublic static int uidToPersonId(LdapService ldapSvc, String uid) throws NamingException, NotFoundException, LdapDataException
ldapSvc - an LdapService configured to connect to the relevant serveruid - the uid to convert to a PersonIdNamingException - in case of LDAP errorNotFoundException - if the PersonId cannot be locatedLdapDataException - if issues are found with the data in the LDAPpublic static List<String> processInternalPhones(String rawField)
rawField - the String as stored in a beanpublic static List<String> processExternalPhones(String rawField)
rawField - the String as stored in a beanpublic static List<PersonRecord> searchPersonRecords(LdapService ldapSvc, String filter) throws NamingException, LdapDataException, SizeLimitExceededException
LdapService is unauthenticated then LdapService.searchSmall()
will be used, which will throw a SizeLimitExceededException if the result
limit is exceeded.ldapSvc - an LdapService configured to connect to the relevant serverfilter - the filter to useNamingException - in case of LDAP errorLdapDataException - in case of issues with the data read from the LDAPSizeLimitExceededException - if the result limit is exceededpublic static Map<RoleRecord,PersonRecord> searchRoleRecords(LdapService ldapSvc, String filter) throws NamingException, LdapDataException, SizeLimitExceededException
LdapService is unauthenticated then LdapService.searchSmall()
will be used, which will throw a SizeLimitExceededException if the result
limit is exceeded.ldapSvc - an LdapService configured to connect to the relevant serverfilter - the filter to useNamingException - in case of LDAP errorLdapDataException - in case of issues with the data read from the LDAPSizeLimitExceededException - if the result limit is exceededpublic static List<UnitRecord> searchUnitRecords(LdapService ldapSvc, String filter) throws NamingException, LdapDataException, SizeLimitExceededException
ldapSvc - an LdapService configured to connect to the relevant serverfilter - the filter to useNamingException - in case of LDAP errorLdapDataException - in case of issues with the data read from the LDAPSizeLimitExceededException - if the result limit is exceededpublic static List<GroupRecord> searchGroupRecords(LdapService ldapSvc, String filter, int searchScope) throws NamingException, LdapDataException, SizeLimitExceededException
groupOfNames or posixGroup) using the supplied filter
and search scope, and returns a fully-fledged GroupRecord object for each one found.
The search only looks within ou=groups and ou=unixgroups,ou=config.
The list is sorted before return.ldapSvc - an LdapService configured with sufficient accessfilter - the filter to usesearchScope - the scope within which to search, as defined by SearchControlsGroupRecords, which will be empty if nothing was foundNamingException - in case of LDAP errorLdapDataException - in case of issues with the data read from the LDAPSizeLimitExceededException - if the result limit is exceededpublic static List<GroupRecord> searchGroupRecords(LdapService ldapSvc, String filter) throws NamingException, LdapDataException, SizeLimitExceededException
groupOfNames or posixGroup) using the supplied filter,
and returns a fully-fledged GroupRecord object for each one found.
The search only looks within ou=groups and ou=unixgroups,ou=config.
The list is sorted before return.ldapSvc - an LdapService configured with sufficient accessfilter - the filter to useGroupRecords, which will be empty if nothing was foundNamingException - in case of LDAP errorLdapDataException - in case of issues with the data read from the LDAPSizeLimitExceededException - if the result limit is exceededpublic static boolean isGroupMember(LdapService ldapSvc, String groupCn, String userUid) throws NamingException, LdapDataException, SizeLimitExceededException
groupOfNames.ldapSvc - an LdapService configured to connect to the relevant servergroupCn - The cn of the group to checkuserUid - The username of the user to checktrue if the user is a member of the groupNamingException - in case of LDAP errorLdapDataException - in case of issues with the data read from the LDAPSizeLimitExceededException - if the result limit is exceededpublic static boolean isGroupOwner(LdapService ldapSvc, String groupCn, String userUid) throws NamingException, LdapDataException, SizeLimitExceededException
groupOfNames.ldapSvc - an LdapService configured to connect to the relevant servergroupCn - The cn of the group to checkuserUid - The username of the user to checktrue if the user is a owner of the groupNamingException - in case of LDAP errorLdapDataException - in case of issues with the data read from the LDAPSizeLimitExceededException - if the result limit is exceededpublic static boolean addGroupMember(LdapService ldapSvc, String uid, String groupCn) throws NamingException
groupOfNames without reading the whole
thing in first.ldapSvc - an LdapService configured to connect to the relevant serveruid - the username of the member to addgroupCn - the cn of the group to add a member totrue if the member was added, false if it was already thereNamingException - in case of LDAP errorpublic static boolean removeGroupMember(LdapService ldapSvc, String uid, String groupCn) throws NamingException
groupOfNames without reading the
whole thing in first.ldapSvc - an LdapService configured to connect to the relevant serveruid - the username of the member to removegroupCn - the cn of the group to remove a member fromtrue if the member was removed, false if it wasn't there to removeNamingException - in case of LDAP errorpublic static boolean addGroupOwner(LdapService ldapSvc, String uid, String groupCn) throws NamingException
groupOfNames without reading the whole
thing in first.ldapSvc - an LdapService configured to connect to the relevant serveruid - the username of the owner to addgroupCn - the cn of the group to add an owner totrue if the owner was added, false if it was already thereNamingException - in case of LDAP errorpublic static boolean removeGroupOwner(LdapService ldapSvc, String uid, String groupCn) throws NamingException
groupOfNames without reading the
whole thing in first.ldapSvc - an LdapService configured to connect to the relevant serveruid - the username of the owner to removegroupCn - the cn of the group to remove an owner fromtrue if the owner was removed, false if it wasn't there to removeNamingException - in case of LDAP errorpublic static boolean addPosixGroupMember(LdapService ldapSvc, String uid, String groupCn) throws NamingException
posixGroup without reading the whole
thing in first.ldapSvc - an LdapService configured to connect to the relevant serveruid - the username of the member to addgroupCn - the cn of the group to add a member totrue if the member was added, false if it was already thereNamingException - in case of LDAP errorpublic static boolean removePosixGroupMember(LdapService ldapSvc, String uid, String groupCn) throws NamingException
posixGroup without reading the
whole thing in first.ldapSvc - an LdapService configured to connect to the relevant serveruid - the username of the member to removegroupCn - the cn of the group to remove a member fromtrue if the member was removed, false if it wasn't there to removeNamingException - in case of LDAP errorCopyright © 2018. All rights reserved.