📄 ldapmanager.java
字号:
public String getAlternateBaseDN() {
return alternateBaseDN;
}
/**
* Sets the alternate starting DN that searches for users will performed with.
* Searches will performed on the entire sub-tree under the alternate base DN after
* they are performed on the main base dn.
*
* @param alternateBaseDN the alternate starting DN used for performing searches.
*/
public void setAlternateBaseDN(String alternateBaseDN) {
this.alternateBaseDN = alternateBaseDN;
if (alternateBaseDN == null) {
properties.remove("ldap.alternateBaseDN");
}
else {
properties.put("ldap.alternateBaseDN", alternateBaseDN);
}
}
/**
* Returns the BaseDN for the given username.
*
* @param username username to return its base DN.
* @return the BaseDN for the given username. If no baseDN is found,
* this method will return <tt>null</tt>.
*/
public String getUsersBaseDN(String username) {
try {
findUserDN(username, baseDN);
return baseDN;
}
catch (Exception e) {
try {
if (alternateBaseDN != null) {
findUserDN(username, alternateBaseDN);
return alternateBaseDN;
}
}
catch (Exception ex) {
Log.debug(ex);
}
}
return null;
}
/**
* Returns the starting admin DN that searches for admins will performed with.
* Searches will performed on the entire sub-tree under the admin DN.
*
* @return the starting DN used for performing searches.
*/
public String getAdminDN() {
return adminDN;
}
/**
* Sets the starting admin DN that searches for admins will performed with.
* Searches will performed on the entire sub-tree under the admins DN.
*
* @param adminDN the starting DN used for performing admin searches.
*/
public void setAdminDN(String adminDN) {
this.adminDN = adminDN;
properties.put("ldap.adminDN", adminDN);
}
/**
* Returns the starting admin DN that searches for admins will performed with.
* Searches will performed on the entire sub-tree under the admin DN.
*
* @return the starting DN used for performing searches.
*/
public String getAdminPassword() {
return adminPassword;
}
/**
* Sets the admin password for the LDAP server we're connecting to.
*
* @param adminPassword the admin password for the LDAP server we're
* connecting to.
*/
public void setAdminPassword(String adminPassword) {
this.adminPassword = adminPassword;
properties.put("ldap.adminPassword", adminPassword);
}
/**
* Sets whether an LDAP connection pool should be used or not.
*
* @param connectionPoolEnabled true if an LDAP connection pool should be used.
*/
public void setConnectionPoolEnabled(boolean connectionPoolEnabled) {
this.connectionPoolEnabled = connectionPoolEnabled;
properties.put("ldap.connectionPoolEnabled", Boolean.toString(connectionPoolEnabled));
}
/**
* Returns whether an LDAP connection pool should be used or not.
*
* @return true if an LDAP connection pool should be used.
*/
public boolean isConnectionPoolEnabled() {
return connectionPoolEnabled;
}
/**
* Returns the filter used for searching the directory for users, which includes
* the default filter (username field search) plus any custom-defined search filter.
*
* @return the search filter.
*/
public String getSearchFilter() {
StringBuilder filter = new StringBuilder();
if (searchFilter == null) {
filter.append("(").append(usernameField).append("={0})");
}
else {
filter.append("(&(").append(usernameField).append("={0})");
filter.append(searchFilter).append(")");
}
return filter.toString();
}
/**
* Sets the search filter appended to the default filter when searching for users.
*
* @param searchFilter the search filter appended to the default filter
* when searching for users.
*/
public void setSearchFilter(String searchFilter) {
this.searchFilter = searchFilter;
properties.put("ldap.searchFilter", searchFilter);
}
/**
* Returns true if the entire tree under the base DN will be searched (recursive search)
* when doing LDAP queries (finding users, groups, etc). When false, only a single level
* under the base DN will be searched. The default is <tt>true</tt> which is the best
* option for most LDAP setups. In only a few cases will the directory be setup in such
* a way that it's better to do single level searching.
*
* @return true if the entire tree under the base DN will be searched.
*/
public boolean isSubTreeSearch() {
return subTreeSearch;
}
/**
* Sets whether the entire tree under the base DN will be searched (recursive search)
* when doing LDAP queries (finding users, groups, etc). When false, only a single level
* under the base DN will be searched. The default is <tt>true</tt> which is the best
* option for most LDAP setups. In only a few cases will the directory be setup in such
* a way that it's better to do single level searching.
*
* @param subTreeSearch true if the entire tree under the base DN will be searched.
*/
public void setSubTreeSearch(boolean subTreeSearch) {
this.subTreeSearch = subTreeSearch;
properties.put("ldap.subTreeSearch", String.valueOf(subTreeSearch));
}
/**
* Returns true if LDAP referrals will automatically be followed when found.
*
* @return true if LDAP referrals are automatically followed.
*/
public boolean isFollowReferralsEnabled() {
return followReferrals;
}
/**
* Sets whether LDAP referrals should be automatically followed.
*
* @param followReferrals true if LDAP referrals should be automatically followed.
*/
public void setFollowReferralsEnabled(boolean followReferrals) {
this.followReferrals = followReferrals;
properties.put("ldap.autoFollowReferrals", String.valueOf(followReferrals));
}
/**
* Returns the field name used for groups.
* Value of groupNameField defaults to "cn".
*
* @return the field used for groups.
*/
public String getGroupNameField() {
return groupNameField;
}
/**
* Sets the field name used for groups.
*
* @param groupNameField the field used for groups.
*/
public void setGroupNameField(String groupNameField) {
this.groupNameField = groupNameField;
properties.put("ldap.groupNameField", groupNameField);
}
/**
* Return the field used to list members within a group.
* Value of groupMemberField defaults to "member".
*
* @return the field used to list members within a group.
*/
public String getGroupMemberField() {
return groupMemberField;
}
/**
* Sets the field used to list members within a group.
* Value of groupMemberField defaults to "member".
*
* @param groupMemberField the field used to list members within a group.
*/
public void setGroupMemberField(String groupMemberField) {
this.groupMemberField = groupMemberField;
properties.put("ldap.groupMemberField", groupMemberField);
}
/**
* Return the field used to describe a group.
* Value of groupDescriptionField defaults to "description".
*
* @return the field used to describe a group.
*/
public String getGroupDescriptionField() {
return groupDescriptionField;
}
/**
* Sets the field used to describe a group.
* Value of groupDescriptionField defaults to "description".
*
* @param groupDescriptionField the field used to describe a group.
*/
public void setGroupDescriptionField(String groupDescriptionField) {
this.groupDescriptionField = groupDescriptionField;
properties.put("ldap.groupDescriptionField", groupDescriptionField);
}
/**
* Return true if the LDAP server is operating in Posix mode. By default
* false is returned. When in Posix mode, users are stored within a group
* by their username alone. When not enabled, users are stored in a group using
* their entire DN.
*
* @return true if posix mode is being used by the LDAP server.
*/
public boolean isPosixMode() {
return posixMode;
}
/**
* Sets whether the LDAP server is operating in Posix mode. When in Posix mode,
* users are stored within a group by their username alone. When not enabled,
* users are stored in a group using their entire DN.
*
* @param posixMode true if posix mode is being used by the LDAP server.
*/
public void setPosixMode(boolean posixMode) {
this.posixMode = posixMode;
properties.put("ldap.posixMode", String.valueOf(posixMode));
}
/**
* Returns the filter used for searching the directory for groups, which includes
* the default filter plus any custom-defined search filter.
*
* @return the search filter when searching for groups.
*/
public String getGroupSearchFilter() {
StringBuilder groupFilter = new StringBuilder();
if (groupSearchFilter == null) {
groupFilter.append("(").append(groupNameField).append("={0})");
}
else {
groupFilter.append("(&(").append(groupNameField).append("={0})");
groupFilter.append(groupSearchFilter).append(")");
}
return groupFilter.toString();
}
/**
* Sets the search filter appended to the default filter when searching for groups.
*
* @param groupSearchFilter the search filter appended to the default filter
* when searching for groups.
*/
public void setGroupSearchFilter(String groupSearchFilter) {
this.groupSearchFilter = groupSearchFilter;
properties.put("ldap.groupSearchFilter", groupSearchFilter);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -