本文整理汇总了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);
}