當前位置: 首頁>>代碼示例>>Java>>正文


Java DirContext.REPLACE_ATTRIBUTE屬性代碼示例

本文整理匯總了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);
	}
}
 
開發者ID:ligoj,項目名稱:plugin-id-ldap,代碼行數:29,代碼來源:UserLdapRepository.java

示例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));
   }
 
開發者ID:costea7,項目名稱:ChronoBike,代碼行數:14,代碼來源:LdapUtil.java

示例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);
}
 
開發者ID:ligoj,項目名稱:plugin-id-ldap,代碼行數:15,代碼來源:UserLdapRepository.java


注:本文中的javax.naming.directory.DirContext.REPLACE_ATTRIBUTE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。