本文整理匯總了Java中javax.naming.directory.DirContext.REPLACE_ATTRIBUTE屬性的典型用法代碼示例。如果您正苦於以下問題:Java DirContext.REPLACE_ATTRIBUTE屬性的具體用法?Java DirContext.REPLACE_ATTRIBUTE怎麽用?Java DirContext.REPLACE_ATTRIBUTE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類javax.naming.directory.DirContext
的用法示例。
在下文中一共展示了DirContext.REPLACE_ATTRIBUTE屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: lock
/**
* Lock an user :
* <ul>
* <li>Clear the password to prevent new authentication</li>
* <li>Set the disabled flag.</li>
* </ul>
*
* @param principal
* User requesting the lock.
* @param user
* The LDAP user to disable.
* @param isolate
* When <code>true</code>, the user will be isolated in addition.
*/
private void lock(final String principal, final UserOrg user, final boolean isolate) {
if (user.getLockedBy() == null) {
// Not yet locked
final ModificationItem[] mods = new ModificationItem[2];
final long timeInMillis = DateUtils.newCalendar().getTimeInMillis();
mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute(lockedAttribute,
String.format("%s|%s|%s|%s|", lockedValue, timeInMillis, principal, isolate ? user.getCompany() : "")));
mods[1] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute(PASSWORD_ATTRIBUTE, null));
template.modifyAttributes(org.springframework.ldap.support.LdapUtils.newLdapName(user.getDn()), mods);
// Also update the disabled date
user.setLocked(new Date(timeInMillis));
user.setLockedBy(principal);
}
}
示例2: replaceAttribute
/**
* @param dn
* @param attributeName
* @param newValue
* @throws NamingException
*/
public void replaceAttribute(String dn, String attributeName, String newValue) throws NamingException
{
Log.logDebug("attribute "+attributeName+" old value is "+getOneAttribute(dn, attributeName));
ModificationItem[] mods = new ModificationItem[1];
mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute(attributeName, newValue));
m_ctx.modifyAttributes(dn, mods);
Log.logDebug("attribute "+attributeName+" new value is "+getOneAttribute(dn, attributeName));
}
示例3: set
/**
* Replace a value by another one without touching other values.
*
* @param dn
* the DN of entry.
* @param attribute
* The attribute name, single value.
* @param value
* the new value.
*/
public void set(final Name dn, final String attribute, final String value) {
final ModificationItem[] mods = new ModificationItem[1];
mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute(attribute, value));
template.modifyAttributes(org.springframework.ldap.support.LdapUtils.newLdapName(dn), mods);
}