javax.naming.directory.AttributeInUseException Java Examples

The following examples show how to use javax.naming.directory.AttributeInUseException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EmissaryServer.java    From emissary with Apache License 2.0 5 votes vote down vote up
private void bindServer() throws UnknownHostException, AttributeInUseException {
    if (Namespace.exists(getDefaultNamespaceName())) {
        LOG.error("EmissaryServer already bound to namespace. This should NEVER happen.");
        throw new AttributeInUseException("EmissaryServer was already bound to the namespace using serverName: " + DEFAULT_NAMESPACE_NAME);
    }

    LOG.debug("Binding {} ", DEFAULT_NAMESPACE_NAME);
    Namespace.bind(getDefaultNamespaceName(), this);

}
 
Example #2
Source File: LDAPUserStoreManager.java    From msf4j with Apache License 2.0 5 votes vote down vote up
public void assignUser(String username, String groupName) throws NamingException {

        try {
            ModificationItem[] mods = new ModificationItem[1];
            Attribute mod = new BasicAttribute("member", getUserDN(username));
            mods[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE, mod);
            context.modifyAttributes(getGroupDN(groupName), mods);
        } catch (AttributeInUseException e) {
            // If user is already added, ignore exception
        }
    }