/** * Reads an entry by its DN. * @param dn distinguished name * @return object * @throws NamingException if DN can not be resolved */ public Object read(final String dn) throws NamingException { return performWithContext(ctx -> ctx.lookup(dn)); }
/** * Perform a lookup against the initial LDAP context, which * sets the context to something appropriate for the search that is about to occur. * */ protected LdapContext createSearchContext(String contextName) throws TranslatorException { try { return (LdapContext) this.ldapConnection.lookup(contextName); } catch (NamingException ne) { throw new TranslatorException(LDAPPlugin.Event.TEIID12002, ne, LDAPPlugin.Util.gs(LDAPPlugin.Event.TEIID12002, contextName)); } }
/** * Tests if an Active Directory user exists in an Active Directory group. * @param ctx LDAP Context. * @param dnADGroup distinguishedName of group. * @param dnADUser distinguishedName of user. * @return True if user is member of group. */ public static boolean isMemberOfADGroup(LdapContext ctx, String dnADGroup, String dnADUser) { try { DirContext lookedContext = (DirContext) (ctx.lookup(dnADGroup)); Attribute attrs = lookedContext.getAttributes("").get("member"); for (int i = 0; i < attrs.size(); i++) { String foundMember = (String) attrs.get(i); if(foundMember.equals(dnADUser)) { return true; } } } catch (NamingException ex) { String msg = "There has been an error trying to determin a group membership for AD user with distinguishedName: "+dnADUser; System.out.println(msg); ex.printStackTrace(); } return false; }
@Override public void removeUser(String username, LdapContext context, LdapAuthConfiguration configuration) throws NoSuchLdapUserException, LdapDAOException { log.info("Remove user: " + username); try { context = (LdapContext) context.lookup(StringUtils.defaultString(configuration.getUserBaseDn(), "")); context.destroySubcontext(configuration.getUserIdAttribute() + "=" + username); } catch (NamingException e) { String message = "Failed to remove user: " + username; throw new LdapDAOException(message, e); } }
/** * Creates a preferences object using a relative name. */ public ServerSystemPreferences(ServerSystemPreferences parent, String name) { super( parent, name ); LdapContext parentCtx = parent.getLdapContext(); try { ctx = ( LdapContext ) parentCtx.lookup( "prefNodeName=" + name ); super.newNode = false; } catch ( NamingException e ) { super.newNode = true; } if ( super.newNode ) { try { setUpNode( name ); } catch ( Exception e ) { throw new ServerSystemPreferenceException( "Failed to set up node.", e ); } } }
public void removeUser( String username, LdapContext context, LdapAuthConfiguration configuration ) throws NoSuchLdapUserException, LdapDAOException { getLogger().info( "Searching for user: " + username ); try { context = (LdapContext) context.lookup( StringUtils.defaultString( configuration.getUserBaseDn(), "" ) ); context.destroySubcontext( configuration.getUserIdAttribute() + "=" + username ); } catch ( NamingException e ) { String message = "Failed to remove user: " + username; throw new LdapDAOException( message, e ); } }
ctx2 = (LdapContext) ctx.lookup(entry.dn);
ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, userDN); ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, password); ctx.lookup(userDN); logger.debug("Authentication successful for {}", userDN);
ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, userDN); ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, password); ctx.lookup(userDN); logger.debug("Authentication successful for {}", userDN);
ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, userDN); ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, password); ctx.lookup(userDN); logger.debug("Authentication successful for {}", userDN);
subContext = (LdapContext)ldapContext.lookup(jndiName);
ctx.lookup( principal.toString() );
ldapCtx = (LdapContext)this.ldapConnection.lookup(""); //$NON-NLS-1$ } catch (NamingException ne) { throw new TranslatorException(ne, LDAPPlugin.Util.getString("LDAPUpdateExecution.createContextError",ne.getExplanation()));//$NON-NLS-1$
ldapCtx = (LdapContext)this.ldapConnection.lookup(""); //$NON-NLS-1$ } catch (NamingException ne) { final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.createContextError",ne.getExplanation()); //$NON-NLS-1$
ctx.lookup(membershipTypeDN);
/** * Sets up a new ServerPreferences node by injecting the required information * such as the node name attribute and the objectClass attribute. * * @param name the name of the new ServerPreferences node. */ private void setUpNode( String name ) throws NamingException { Attributes attrs = new LockableAttributesImpl(); Attribute attr = new LockableAttributeImpl( "objectClass" ); attr.add( "top" ); attr.add( "prefNode" ); attr.add( "extensibleObject" ); attrs.put( attr ); attr = new LockableAttributeImpl( "prefNodeName" ); attr.add( name ); attrs.put( attr ); LdapContext parent = ( ( ServerSystemPreferences ) parent() ).getLdapContext(); parent.bind( "prefNodeName=" + name, null, attrs ); ctx = ( LdapContext ) parent.lookup( "prefNodeName=" + name ); super.newNode = false; }
userContext = (LdapContext) context.lookup(userBaseDn);
userContext = (LdapContext) context.lookup( userBaseDn );
userContext = (LdapContext) context.lookup(userBaseDn);