本文整理汇总了Java中com.unboundid.ldap.sdk.LDAPConnection.add方法的典型用法代码示例。如果您正苦于以下问题:Java LDAPConnection.add方法的具体用法?Java LDAPConnection.add怎么用?Java LDAPConnection.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.unboundid.ldap.sdk.LDAPConnection
的用法示例。
在下文中一共展示了LDAPConnection.add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLdapEntries
import com.unboundid.ldap.sdk.LDAPConnection; //导入方法依赖的package包/类
/**
* Creates the given LDAP entries.
*
* @param connection Open LDAP connection used to connect to directory.
* @param entries Collection of LDAP entries.
*
* @throws Exception On LDAP errors.
*/
public static void createLdapEntries(final LDAPConnection connection, final Collection<LdapEntry> entries) throws Exception {
for (final LdapEntry entry : entries) {
final Collection<Attribute> attrs = new ArrayList<>(entry.getAttributeNames().length);
for (final LdapAttribute a : entry.getAttributes()) {
attrs.add(new Attribute(a.getName(), a.getStringValues()));
}
connection.add(new AddRequest(entry.getDn(), attrs));
}
}
示例2: createLdapEntries
import com.unboundid.ldap.sdk.LDAPConnection; //导入方法依赖的package包/类
/**
* Creates the given LDAP entries.
*
* @param connection Open LDAP connection used to connect to directory.
* @param entries Collection of LDAP entries.
* @throws Exception On LDAP errors.
*/
public static void createLdapEntries(final LDAPConnection connection, final Collection<LdapEntry> entries) throws Exception {
try {
for (final LdapEntry entry : entries) {
final Collection<Attribute> attrs = new ArrayList<>(entry.getAttributeNames().length);
attrs.addAll(entry.getAttributes().stream()
.map(a -> new Attribute(a.getName(), a.getStringValues())).collect(Collectors.toList()));
final AddRequest ad = new AddRequest(entry.getDn(), attrs);
connection.add(ad);
}
} catch (final Exception e) {
LOGGER.warn(e.getLocalizedMessage());
}
}