Examples of InitialDirContext


Examples of javax.naming.directory.InitialDirContext

      System.out.println("Credentials: " + this.getProperty(DirectoryAuthentication.AUTH_PASSWORD));
      // Set the authentication password
      environment.put(Context.SECURITY_CREDENTIALS, this.getProperty(DirectoryAuthentication.AUTH_PASSWORD));

      // Create the LDAP context with the environment setup
      dirContext = new InitialDirContext(environment);
    }
    catch (Exception e)
    {
      throw e;
    }
View Full Code Here

Examples of javax.naming.directory.InitialDirContext

  {
    Hashtable env = new Hashtable();
   
    env.put ("java.naming.factory.initial", getFactory());
   
    return( new InitialDirContext( env ));

  }
View Full Code Here

Examples of javax.naming.directory.InitialDirContext

        long started = System.currentTimeMillis();
        Context context;
        if (ctxclass.equalsIgnoreCase("ldap")) {
          context = new InitialLdapContext(properties, null);
        } else if (ctxclass.equalsIgnoreCase("directory")) {
          context = new InitialDirContext(properties);
        } else {
          context = new InitialContext(properties);
        }
       
        //this.pool.getZone().log().info("Created context: "+context+" with params: "+properties);
View Full Code Here

Examples of javax.naming.directory.InitialDirContext

    log.info("Server: " + baseURI);
    log.info("filter: " + queryString);
    log.info("get attributes: " + join(toGet, ","));
   

    DirContext context = new InitialDirContext();
   
    NamingEnumeration<SearchResult> results = null;
   
    if ("".equals(queryString)) // We aren't searching, just get attributes
    {
      Attributes attrs = context.getAttributes(baseURI, (String[]) toGet
          .toArray(new String[] {}));
      // Wrap this to fit this method's contract
      SearchResult sr = new SearchResult(null, null, attrs);
      sr.setNameInNamespace(uriToName(baseURI));
      results = new SingletonNamingEnumeration<SearchResult>(sr);
    }
    else // An actual query
    {
      SearchControls sc = new SearchControls();
      sc.setReturningAttributes(toGet.toArray(new String[] {}));
      sc.setSearchScope(SearchControls.SUBTREE_SCOPE);
     
      results = context.search(baseURI, queryString, sc);
    }

    return results;
  }
View Full Code Here

Examples of javax.naming.directory.InitialDirContext

 
  protected void setUp() throws Exception
  {
    super.setUp();
    Logger.getLogger(LdapTest.class).setLevel(Level.DEBUG);
    context = new InitialDirContext();
    config = FileManager.get().loadModel("examples/ldap_map.n3");
  }
View Full Code Here

Examples of javax.naming.directory.InitialDirContext

    /** This method should read the configuration and then
     * set the categories and properties.
     * @throws ConfigurationManagerException
     */
    public Configuration load(String configurationName) throws ConfigurationManagerException {   
        InitialDirContext ctx = getContext();
        if ( ctx == null ) {
            throw new ConfigurationManagerException("There is no connection to the LDAP server");
        }
        Configuration config = new DefaultConfiguration(null);
        getCategories(ctx,config);
View Full Code Here

Examples of javax.naming.directory.InitialDirContext

            env.put(Context.PROVIDER_URL, props.getProperty("Host", ""));
            env.put(Context.SECURITY_AUTHENTICATION, "simple");
            env.put(Context.SECURITY_PRINCIPAL, props.getProperty("RootDN", ""));
            env.put(Context.SECURITY_CREDENTIALS, props.getProperty("Password", ""));
            baseDN = props.getProperty("BaseDN","");
            return new InitialDirContext(env);
        }
        catch (Exception e) {
          ErrorReporter.getErrorHandler().reportError(e.getLocalizedMessage(), e);
            return null;
        }
View Full Code Here

Examples of javax.naming.directory.InitialDirContext

  public static List<MXRecord> getMXServers(final String domain){
     final Hashtable<String, String> env = new Hashtable<String, String>();
     env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory"); //$NON-NLS-1$ //$NON-NLS-2$
    
     try{
       final DirContext ictx = new InitialDirContext( env );
       final Attributes attrs = ictx.getAttributes( domain, new String[] { "MX" }); //$NON-NLS-1$
    
       final Attribute attr = attrs.get( "MX" ); //$NON-NLS-1$
    
       if( attr == null || attr.size() == 0){
         return null;
View Full Code Here

Examples of javax.naming.directory.InitialDirContext

        showError("delete.error.lock");
      } else {
        deletStartLink.setEnabled(false);

        // check and get LDAP connection
        InitialDirContext ctx = LDAPLoginManager.getInstance().bindSystem();
        if (ctx == null) {
          showError("LDAP connection ERROR");
          return;
        }
        // get deleted users
        identitiesToDelete = LDAPLoginManager.getInstance().getIdentitysDeletedInLdap(ctx);
        try {
          ctx.close();
        } catch (NamingException e) {
          showError("Could not close LDAP connection on manual delete sync");
          logError("Could not close LDAP connection on manual delete sync", e);
        }
        if (identitiesToDelete != null && identitiesToDelete.size() != 0) {
View Full Code Here

Examples of javax.naming.directory.InitialDirContext

    if (LDAPLoginModule.isSslEnabled()) {
      enableSSL(env);
    }

    try {
      InitialDirContext ctx = new InitialDirContext(env);
      return ctx;
    } catch (NamingException e) {
      log.error("NamingException when trying to bind system with DN::" + LDAPLoginModule.getLdapSystemDN() + " and PW::"
          + LDAPLoginModule.getLdapSystemPW() + " on URL::" + LDAPLoginModule.getLdapUrl(), e);
      return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.