本文整理了Java中com.unboundid.ldap.sdk.LDAPConnection.add()
方法的一些代码示例,展示了LDAPConnection.add()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LDAPConnection.add()
方法的具体详情如下:
包路径:com.unboundid.ldap.sdk.LDAPConnection
类名称:LDAPConnection
方法名:add
[英]Processes the provided add request.
[中]处理提供的添加请求。
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition
/**
* Processes the provided add request.
*
* @param addRequest The add request to be processed. It must not be
* {@code null}.
*
* @return The result of processing the add operation.
*
* @throws LDAPException If the server rejects the add request, or if a
* problem is encountered while sending the request or
* reading the response.
*/
public LDAPResult add(final ReadOnlyAddRequest addRequest)
throws LDAPException
{
return add((AddRequest) addRequest);
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Processes the provided add request.
*
* @param addRequest The add request to be processed. It must not be
* {@code null}.
*
* @return The result of processing the add operation.
*
* @throws LDAPException If the server rejects the add request, or if a
* problem is encountered while sending the request or
* reading the response.
*/
public LDAPResult add(final ReadOnlyAddRequest addRequest)
throws LDAPException
{
return add((AddRequest) addRequest);
}
代码示例来源:origin: com.redhat.lightblue.ldap/lightblue-ldap-hystrix
@Override
protected LDAPResult run() throws Exception {
return getConnection().add(entry);
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Processes an add operation with the provided information.
*
* @param ldifLines The lines that comprise an LDIF representation of the
* entry to add. It must not be empty or {@code null}.
*
* @return The result of processing the add operation.
*
* @throws LDIFException If the provided entry lines cannot be decoded as an
* entry in LDIF form.
*
* @throws LDAPException If the server rejects the add request, or if a
* problem is encountered while sending the request or
* reading the response.
*/
public LDAPResult add(final String... ldifLines)
throws LDIFException, LDAPException
{
return add(new AddRequest(ldifLines));
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition
/**
* Processes an add operation with the provided information.
*
* @param ldifLines The lines that comprise an LDIF representation of the
* entry to add. It must not be empty or {@code null}.
*
* @return The result of processing the add operation.
*
* @throws LDIFException If the provided entry lines cannot be decoded as an
* entry in LDIF form.
*
* @throws LDAPException If the server rejects the add request, or if a
* problem is encountered while sending the request or
* reading the response.
*/
public LDAPResult add(final String... ldifLines)
throws LDIFException, LDAPException
{
return add(new AddRequest(ldifLines));
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Processes an add operation with the provided information.
*
* @param entry The entry to add. It must not be {@code null}.
*
* @return The result of processing the add operation.
*
* @throws LDAPException If the server rejects the add request, or if a
* problem is encountered while sending the request or
* reading the response.
*/
public LDAPResult add(final Entry entry)
throws LDAPException
{
ensureNotNull(entry);
return add(new AddRequest(entry));
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition
/**
* Processes an add operation with the provided information.
*
* @param entry The entry to add. It must not be {@code null}.
*
* @return The result of processing the add operation.
*
* @throws LDAPException If the server rejects the add request, or if a
* problem is encountered while sending the request or
* reading the response.
*/
public LDAPResult add(final Entry entry)
throws LDAPException
{
ensureNotNull(entry);
return add(new AddRequest(entry));
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition
/**
* Processes an add operation with the provided information.
*
* @param dn The DN of the entry to add. It must not be
* {@code null}.
* @param attributes The set of attributes to include in the entry to add.
* It must not be {@code null}.
*
* @return The result of processing the add operation.
*
* @throws LDAPException If the server rejects the add request, or if a
* problem is encountered while sending the request or
* reading the response.
*/
public LDAPResult add(final String dn, final Attribute... attributes)
throws LDAPException
{
ensureNotNull(dn, attributes);
return add(new AddRequest(dn, attributes));
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition
/**
* Processes an add operation with the provided information.
*
* @param dn The DN of the entry to add. It must not be
* {@code null}.
* @param attributes The set of attributes to include in the entry to add.
* It must not be {@code null}.
*
* @return The result of processing the add operation.
*
* @throws LDAPException If the server rejects the add request, or if a
* problem is encountered while sending the request or
* reading the response.
*/
public LDAPResult add(final String dn, final Collection<Attribute> attributes)
throws LDAPException
{
ensureNotNull(dn, attributes);
return add(new AddRequest(dn, attributes));
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Processes an add operation with the provided information.
*
* @param dn The DN of the entry to add. It must not be
* {@code null}.
* @param attributes The set of attributes to include in the entry to add.
* It must not be {@code null}.
*
* @return The result of processing the add operation.
*
* @throws LDAPException If the server rejects the add request, or if a
* problem is encountered while sending the request or
* reading the response.
*/
public LDAPResult add(final String dn, final Attribute... attributes)
throws LDAPException
{
ensureNotNull(dn, attributes);
return add(new AddRequest(dn, attributes));
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Processes an add operation with the provided information.
*
* @param dn The DN of the entry to add. It must not be
* {@code null}.
* @param attributes The set of attributes to include in the entry to add.
* It must not be {@code null}.
*
* @return The result of processing the add operation.
*
* @throws LDAPException If the server rejects the add request, or if a
* problem is encountered while sending the request or
* reading the response.
*/
public LDAPResult add(final String dn, final Collection<Attribute> attributes)
throws LDAPException
{
ensureNotNull(dn, attributes);
return add(new AddRequest(dn, attributes));
}
代码示例来源:origin: hlavki/g-suite-identity-sync
private void creatOrgUnits(LDAPConnection conn) throws LDAPException {
String peopleDn = config.getLdapUserBaseDN();
if (conn.getEntry(peopleDn) == null) {
Entry entry = new Entry(peopleDn);
entry.addAttribute("objectClass", "top");
entry.addAttribute("objectClass", "organizationalUnit");
conn.add(entry);
}
String groupDn = config.getLdapGroupsBaseDN();
if (conn.getEntry(groupDn) == null) {
Entry entry = new Entry(groupDn);
entry.addAttribute("objectClass", "top");
entry.addAttribute("objectClass", "organizationalUnit");
conn.add(entry);
}
}
代码示例来源:origin: io.vertx/vertx-auth-shiro
private void insertTestUsers() throws LDAPException {
LDAPConnection connection = null;
try {
connection = new LDAPConnection("localhost", 10389);
// entry tim/sausages
List<Attribute> addRequest = new ArrayList<>();
addRequest.add(new Attribute("objectClass", "top"));
addRequest.add(new Attribute("objectClass", "person"));
addRequest.add(new Attribute("objectClass", "organizationalPerson"));
addRequest.add(new Attribute("objectClass", "inetOrgPerson"));
addRequest.add(new Attribute("cn", "Tim Fox"));
addRequest.add(new Attribute("sn", "Fox"));
addRequest.add(new Attribute("mail", "tim@example.com"));
addRequest.add(new Attribute("uid", "tim"));
addRequest.add(new Attribute("userPassword", "{ssha}d0M5Z2qjOOCSCQInvZHgVAleCqU5I+ag9ZHXMw=="));
connection.add("uid=tim,ou=users,dc=foo,dc=com", addRequest);
} finally {
if (connection != null) {
connection.close();
}
}
}
代码示例来源:origin: io.vertx/vertx-auth-service
private void insertTestUsers() throws LDAPException {
LDAPConnection connection = null;
try {
connection = new LDAPConnection("localhost", 10389);
// entry tim/sausages
List<Attribute> addRequest = new ArrayList<Attribute>();
addRequest.add(new Attribute("objectClass", "top"));
addRequest.add(new Attribute("objectClass", "person"));
addRequest.add(new Attribute("objectClass", "organizationalPerson"));
addRequest.add(new Attribute("objectClass", "inetOrgPerson"));
addRequest.add(new Attribute("cn", "Tim Fox"));
addRequest.add(new Attribute("sn", "Fox"));
addRequest.add(new Attribute("mail", "tim@example.com"));
addRequest.add(new Attribute("uid", "tim"));
addRequest.add(new Attribute("userPassword", "{ssha}d0M5Z2qjOOCSCQInvZHgVAleCqU5I+ag9ZHXMw=="));
connection.add("uid=tim,ou=users,dc=foo,dc=com", addRequest);
} finally {
if (connection != null) {
connection.close();
}
}
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Schedules a new instance of the provided task in the Directory Server.
*
* @param task The task to be scheduled.
* @param connection The connection to the Directory Server in which the
* task is to be scheduled.
*
* @return A {@code Task} object representing the task that was scheduled and
* re-read from the server.
*
* @throws LDAPException If a problem occurs while communicating with the
* Directory Server, or if it rejects the task.
*
* @throws TaskException If the entry read back from the server after the
* task was created could not be parsed as a task.
*/
public static Task scheduleTask(final Task task,
final LDAPConnection connection)
throws LDAPException, TaskException
{
final Entry taskEntry = task.createTaskEntry();
connection.add(task.createTaskEntry());
final Entry newTaskEntry = connection.getEntry(taskEntry.getDN());
if (newTaskEntry == null)
{
// This should never happen.
throw new LDAPException(ResultCode.NO_SUCH_OBJECT);
}
return Task.decodeTask(newTaskEntry);
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Adds the provided entry to the directory.
*
* @param entry The entry to be added.
* @param constraints The constraints to use for the add operation.
*
* @throws LDAPException If a problem occurs while adding the entry.
*/
public void add(final LDAPEntry entry, final LDAPConstraints constraints)
throws LDAPException
{
final AddRequest addRequest = new AddRequest(entry.toEntry());
update(addRequest, constraints);
try
{
final LDAPResult result = conn.add(addRequest);
setResponseControls(result);
}
catch (com.unboundid.ldap.sdk.LDAPException le)
{
debugException(le);
setResponseControls(le);
throw new LDAPException(le);
}
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
try
addResult = ldapConnection.add(addRequest);
代码示例来源:origin: hlavki/g-suite-identity-sync
@Override
public void addGroupMember(String accountDN, String groupName) throws LdapSystemException {
try (LDAPConnection conn = ldapPool.getConnection()) {
LdapGroup group = getGroup(groupName, conn);
if (group != null && group.getMembersDn().contains(accountDN)) {
log.info("Nothing to do. Account {} is already member of group {}", accountDN, group.getName());
} else {
if (group == null) {
log.debug("Creating group {}", groupName);
DN groupDN = new DN(new RDN(GROUP_NAME_ATTR, groupName), new DN(config.getLdapGroupsBaseDN()));
Entry groupEntry = new Entry(groupDN);
groupEntry.addAttribute("objectClass", config.getLdapGroupsObjectClass());
groupEntry.addAttribute(config.getLdapGroupsMemberAttr(), accountDN);
conn.add(groupEntry);
log.info("Group {} added", groupDN);
} else {
Modification mod = new Modification(ADD, config.getLdapGroupsMemberAttr(), accountDN);
conn.modify(new ModifyRequest(group.getDn(), mod));
log.info("Added membership {} to {}", accountDN, group.getName());
}
}
} catch (LDAPException e) {
throw new LdapSystemException(e);
}
}
代码示例来源:origin: hlavki/g-suite-identity-sync
@Override
public void createAccount(LdapAccount account) throws LdapSystemException {
try (LDAPConnection conn = ldapPool.getConnection()) {
String entryDN = getAccountDN(account);
log.info("Creating user with DN {}", entryDN);
Entry entry = new Entry(entryDN);
entry.addAttribute("objectClass", "inetOrgPerson");
for (String email : account.getEmails()) {
entry.addAttribute("mail", email);
}
entry.addAttribute("givenName", account.getGivenName());
entry.addAttribute("sn", account.getFamilyName());
entry.addAttribute("cn", account.getName());
entry.addAttribute("employeeNumber", account.getSubject());
entry.addAttribute("userPassword", account.getPassword());
entry.addAttribute("employeeType", account.getRole().toString());
conn.add(entry);
} catch (LDAPException e) {
throw new LdapSystemException(e);
}
}
代码示例来源:origin: hlavki/g-suite-identity-sync
@Override
public LdapGroup createOrUpdateGroup(LdapGroup group) throws LdapSystemException {
try (LDAPConnection conn = ldapPool.getConnection()) {
LdapGroup current = getGroup(group.getName(), conn);
if (current != null) {
Modification[] mods = new Modification[]{
new Modification(REPLACE, GROUP_DESC_ATTR, group.getDescription()),
new Modification(REPLACE, config.getLdapGroupsMemberAttr(), group.getMembersDn().toArray(new String[0]))
};
conn.modify(current.getDn(), mods);
current.setDescription(group.getDescription());
current.setMembersDn(group.getMembersDn());
} else {
String dn = getGroupDN(group.getName());
Entry entry = new Entry(dn);
entry.setAttribute(GROUP_NAME_ATTR, group.getName());
entry.setAttribute(GROUP_DESC_ATTR, group.getDescription());
entry.setAttribute(config.getLdapGroupsMemberAttr(), group.getMembersDn());
entry.setAttribute("objectClass", config.getLdapGroupsObjectClass());
conn.add(entry);
current = new LdapGroup(dn, group.getName(), group.getDescription(), group.getMembersDn());
}
return current;
} catch (LDAPException e) {
throw new LdapSystemException(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!