本文整理汇总了Java中javax.naming.ldap.LdapContext.modifyAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java LdapContext.modifyAttributes方法的具体用法?Java LdapContext.modifyAttributes怎么用?Java LdapContext.modifyAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.naming.ldap.LdapContext
的用法示例。
在下文中一共展示了LdapContext.modifyAttributes方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateLdapZimbra
import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
public void updateLdapZimbra(LdapContext ctx ,User user,String name, Employee emp) throws NamingException{
Modifications mods = Modifications.getInstance();
for (int i = 0; i < 5;i++){
mods.addItem(zimbraProperty[i][0],zimbraProperty[i][1]);
}
mods.addItem("zimbramaildeliveryaddress",user.getEmailAddress());
// mods.addItem("company",user.getEmailAddress());
// mods.addItem("street",user.getEmailAddress());
//.addItem("company",user.getEmailAddress());
// mods.addItem("company",user.getEmailAddress());
//System.out.println("My " + mods);
ModificationItem[] modItems = mods.getItems();
ctx.modifyAttributes(name, modItems);
//= getContext(serviceContext.getCompanyId());
}
示例2: defineTriggerExecutionSpecificPoint
import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
/**
* Defines the Administration point and administrative role for the TriggerExecution specific point
* @param apCtx The administrative point context
* @throws NamingException If the operation failed
*/
public static void defineTriggerExecutionSpecificPoint( LdapContext apCtx ) throws NamingException
{
Attributes ap = apCtx.getAttributes( "", new String[] { SchemaConstants.ADMINISTRATIVE_ROLE_AT } );
Attribute administrativeRole = ap.get( SchemaConstants.ADMINISTRATIVE_ROLE_AT );
if ( administrativeRole == null
|| !AttributeUtils.containsValueCaseIgnore( administrativeRole, SchemaConstants.TRIGGER_EXECUTION_SPECIFIC_AREA ) )
{
Attributes changes = new BasicAttributes( SchemaConstants.ADMINISTRATIVE_ROLE_AT,
SchemaConstants.TRIGGER_EXECUTION_SPECIFIC_AREA, true );
apCtx.modifyAttributes( "", DirContext.ADD_ATTRIBUTE, changes );
}
}
示例3: changePassord
import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
public void changePassord(ServiceContext serviceContext, User user, String password) throws Exception{
long companyId = serviceContext.getCompanyId();
Properties userMappings = getUserMappings(serviceContext.getCompanyId());
Binding binding = getUser(companyId, user.getScreenName());
System.out.println("bingging " + binding);
System.out.println("Pass " + user.getPassword());
String name = StringPool.BLANK;
StringBuilder sb = new StringBuilder();
LdapContext ctx = getContext(serviceContext.getCompanyId());
sb = new StringBuilder();
sb.append(userMappings.getProperty("screenName"));
sb.append(StringPool.EQUAL);
sb.append(user.getScreenName());
sb.append(StringPool.COMMA);
sb.append(getUsersDN(companyId));
name = sb.toString();
Modifications mods = Modifications.getInstance();
mods.addItem(userMappings.getProperty(UserConverterKeys.PASSWORD),password);
ModificationItem[] modItems = mods.getItems();
if (binding != null) {
ctx.modifyAttributes(name, modItems);
}
}
示例4: loadPrescriptiveTriggerSpecification
import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
/**
* Load an prescriptive trigger specification
*
* @param apCtx The administrative point context
* @param subentryCN The subentry CN
* @param triggerSpec The trigger specification
* @throws NamingException If the operation failed
*/
public static void loadPrescriptiveTriggerSpecification(
LdapContext apCtx,
String subentryCN,
String triggerSpec ) throws NamingException
{
Attributes changes = new BasicAttributes( SchemaConstants.PRESCRIPTIVE_TRIGGER_SPECIFICATION_AT, triggerSpec, true );
apCtx.modifyAttributes( "cn=" + subentryCN, DirContext.ADD_ATTRIBUTE, changes );
}
示例5: loadEntryTriggerSpecification
import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
/**
* Load the trigger specification entry
*
* @param ctx The context
* @param triggerSpec The trigger specification
* @throws NamingException If the operation failed
*/
public static void loadEntryTriggerSpecification(
LdapContext ctx,
String triggerSpec ) throws NamingException
{
Attributes changes = new BasicAttributes( SchemaConstants.ENTRY_TRIGGER_SPECIFICATION_AT, triggerSpec, true );
ctx.modifyAttributes( "", DirContext.ADD_ATTRIBUTE, changes );
}
示例6: deleteStringAttributeValue
import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
@LdapOperation
@ModifyOperation
public final void deleteStringAttributeValue( final String entryDN, final String attributeName, final String attributeValue )
throws ChaiUnavailableException, ChaiOperationException
{
activityPreCheck();
getInputValidator().deleteStringAttributeValue( entryDN, attributeName, attributeValue );
// Create a BasicAttribute for the object.
final BasicAttribute attributeToReplace = new BasicAttribute( attributeName, attributeValue );
// Create the ModificationItem
final ModificationItem[] modificationItem = new ModificationItem[1];
// Populate the ModificationItem object with the flag & the attribute to replace.
modificationItem[0] = new ModificationItem( DirContext.REMOVE_ATTRIBUTE, attributeToReplace );
// Modify the Attributes.
final LdapContext ldapConnection = getLdapConnection();
try
{
ldapConnection.modifyAttributes( addJndiEscape( entryDN ), modificationItem );
}
catch ( NamingException e )
{
convertNamingException( e );
}
}
示例7: replaceStringAttribute
import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
@LdapOperation
@ModifyOperation
public final void replaceStringAttribute( final String entryDN, final String attributeName, final String oldValue, final String newValue )
throws ChaiUnavailableException, ChaiOperationException
{
activityPreCheck();
getInputValidator().replaceStringAttribute( entryDN, attributeName, oldValue, newValue );
// Create the ModificationItem
final ModificationItem[] mods = new ModificationItem[2];
// Mark the flag to remover the existing attribute.
mods[0] = new ModificationItem( DirContext.REMOVE_ATTRIBUTE, new BasicAttribute( attributeName, oldValue ) );
// Mark the flag to add the new attribute
mods[1] = new ModificationItem( DirContext.ADD_ATTRIBUTE, new BasicAttribute( attributeName, newValue ) );
// get ldap connection
final LdapContext ldapConnection = getLdapConnection();
// Modify the Attributes.
try
{
ldapConnection.modifyAttributes( addJndiEscape( entryDN ), mods );
}
catch ( NamingException e )
{
convertNamingException( e );
}
}
示例8: writeStringAttribute
import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
@LdapOperation
@ModifyOperation
public final void writeStringAttribute( final String entryDN, final String attributeName, final Set<String> values, final boolean overwrite )
throws ChaiUnavailableException, ChaiOperationException
{
activityPreCheck();
getInputValidator().writeStringAttribute( entryDN, attributeName, values, overwrite );
// Create the ModificationItem
final ModificationItem[] modificationItem = new ModificationItem[values.size()];
int loopCounter = 0;
for ( final String value : values )
{
// Create a BasicAttribute for the object.
final BasicAttribute attributeToReplace = new BasicAttribute( attributeName, value );
// Determine the modification type, if replace, only replace on the first attribute, the rest just get added.
final int modType = ( loopCounter == 0 && overwrite ) ? DirContext.REPLACE_ATTRIBUTE : DirContext.ADD_ATTRIBUTE;
// Populate the ModificationItem object with the flag & the attribute to replace.
modificationItem[loopCounter] = new ModificationItem( modType, attributeToReplace );
loopCounter++;
}
// get ldap connection
final LdapContext ldapConnection = getLdapConnection();
// Modify the Attributes.
try
{
ldapConnection.modifyAttributes( addJndiEscape( entryDN ), modificationItem );
}
catch ( NamingException e )
{
LOGGER.trace( "error during write of attribute '" + attributeName + "', error: " + e.getMessage() );
convertNamingException( e );
}
}
示例9: updateLdapZimbra
import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
public void updateLdapZimbra(LdapContext ctx ,User user,String name) throws NamingException{
Modifications mods = Modifications.getInstance();
for (int i = 0; i < 5;i++){
mods.addItem(zimbraProperty[i][0],zimbraProperty[i][1]);
}
mods.addItem("zimbramaildeliveryaddress",user.getEmailAddress());
ModificationItem[] modItems = mods.getItems();
ctx.modifyAttributes(name, modItems);
//= getContext(serviceContext.getCompanyId());
}
示例10: updateLdapEmployee
import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
public void updateLdapEmployee(LdapContext ctx, Employee emp,Properties userMappings,String name) throws NamingException{
Modifications mods = Modifications.getInstance();
mods.addItem("homephone",emp.getHomeTel());
mods.addItem("mobile",emp.getMobile());
mods.addItem("zimbramaildeliveryaddress",emp.getEmail());
// mods.a
String[] tg = emp.getFullName().split(" ");
String firstName = tg[0];
String middleName = "";
String lastName = "";
if (tg.length > 1) {
firstName = tg[tg.length - 1];
lastName = tg[0];
}
if (tg.length > 2) {
middleName = tg[1];
for (int i = 2; i < tg.length - 1; i++) {
middleName += " " + tg[i];
}
}
mods.addItem(userMappings.getProperty(UserConverterKeys.EMAIL_ADDRESS),emp.getEmail());
mods.addItem(userMappings.getProperty(UserConverterKeys.FULL_NAME),emp.getFullName());
mods.addItem(userMappings.getProperty(UserConverterKeys.FIRST_NAME),firstName);
mods.addItem(userMappings.getProperty(UserConverterKeys.MIDDLE_NAME),middleName);
mods.addItem(userMappings.getProperty(UserConverterKeys.LAST_NAME),lastName);
ModificationItem[] modItems = mods.getItems();
ctx.modifyAttributes(name, modItems);
}
示例11: changeActive
import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
public void changeActive(ServiceContext serviceContext, User user, int active) throws Exception{
long companyId = serviceContext.getCompanyId();
Properties userMappings = getUserMappings(serviceContext.getCompanyId());
Binding binding = getUser(companyId, user.getScreenName());
String name = StringPool.BLANK;
StringBuilder sb = new StringBuilder();
LdapContext ctx = getContext(serviceContext.getCompanyId());
sb = new StringBuilder();
sb.append(userMappings.getProperty("screenName"));
sb.append(StringPool.EQUAL);
sb.append(user.getScreenName());
sb.append(StringPool.COMMA);
sb.append(getUsersDN(companyId));
name = sb.toString();
Modifications mods = Modifications.getInstance();
String[] status = {"locked","active","closed"};
if (getIsZimbraLdap(companyId)){
mods.addItem(userMappings.getProperty(UserConverterKeys.STATUS),status[active]);
}else {
mods.addItem(userMappings.getProperty(UserConverterKeys.STATUS),String.valueOf(active));
}
ModificationItem[] modItems = mods.getItems();
if (binding != null) {
ctx.modifyAttributes(name, modItems);
}
}
示例12: modifyByDn
import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
public void modifyByDn(String dn, List<ModificationItem> modificationItems) {
try {
LdapContext context = connectionService.getContext();
context.modifyAttributes(dn, modificationItems.toArray(new ModificationItem[modificationItems.size()]));
} catch (NamingException e) {
throw new CukesRuntimeException("Cannot modify entity by dn " + dn, e);
} finally {
connectionService.close();
}
}
示例13: writeStringAttributes
import javax.naming.ldap.LdapContext; //导入方法依赖的package包/类
public final void writeStringAttributes(
final String entryDN,
final Map<String, String> attributeValueProps,
final boolean overwrite,
final BasicControl[] controls
)
throws ChaiUnavailableException, ChaiOperationException
{
activityPreCheck();
getInputValidator().writeStringAttributes( entryDN, attributeValueProps, overwrite );
// Determine the modification type, if replace, only replace on the first attribute, the rest just get added.
final int modType = overwrite ? DirContext.REPLACE_ATTRIBUTE : DirContext.ADD_ATTRIBUTE;
// Create the ModificationItem
final List<ModificationItem> modificationItems = new ArrayList<>();
for ( final Map.Entry<String, String> entry : attributeValueProps.entrySet() )
{
// Create a BasicAttribute for the object.
final BasicAttribute attributeToReplace = new BasicAttribute( entry.getKey(), entry.getValue() );
// Populate the ModificationItem object with the flag & the attribute to replace.
modificationItems.add( new ModificationItem( modType, attributeToReplace ) );
}
// convert to array
final ModificationItem[] modificationItemArray = modificationItems.toArray( new ModificationItem[modificationItems.size()] );
// get ldap connection
final LdapContext ldapConnection = getLdapConnection();
// Modify the Attributes.
try
{
ldapConnection.modifyAttributes( addJndiEscape( entryDN ), modificationItemArray );
}
catch ( NamingException e )
{
convertNamingException( e );
}
}