KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > javax > naming > directory > DirContext

javax.naming.directory
Interface DirContext

All Superinterfaces:
Context
All Known Subinterfaces:
EventDirContext, LdapContext
All Known Implementing Classes:
InitialDirContext, InitialLdapContext
See Also:
Top Examples, Source Code

static final int ADD_ATTRIBUTE
See Also:
modifyAttributes(javax.naming.Name, int, javax.naming.directory.Attributes), ModificationItem
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void bind(String name,
          Object obj,
          Attributes attrs)
          throws NamingException
See Also:
InvalidAttributesException, NameAlreadyBoundException, bind(Name, Object, Attributes)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void bind(Name name,
          Object obj,
          Attributes attrs)
          throws NamingException
See Also:
Context.bind(Name, Object), InvalidAttributesException, NameAlreadyBoundException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


DirContext createSubcontext(String name,
                            Attributes attrs)
                            throws NamingException
See Also:
InvalidAttributesException, NameAlreadyBoundException, createSubcontext(Name, Attributes)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


DirContext createSubcontext(Name name,
                            Attributes attrs)
                            throws NamingException
See Also:
Context.createSubcontext(Name), InvalidAttributesException, NameAlreadyBoundException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Attributes getAttributes(String name)
                         throws NamingException
See Also:
getAttributes(Name)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1720]Asking for all attributes given an object and getting then into a hash table.
By oscasc { at } gmail { dot } com on 2006/03/10 12:15:01  Rate
//String base = "CN=Oscar Salgado,O=myOffice"; 
 . 
 . 
 . 
 private Hashtable getAllAttributes_def ( String base )  {  
     Hashtable htable = new Hashtable (  ) ; 
     try {      
       DirContext context = getContext (  ) ; 
       NamingEnumeration atributos = context.getAttributes ( base ) .getAll (  ) ;       
       while ( atributos.hasMore (  )  )  {  
         BasicAttribute atributo =  ( BasicAttribute ) atributos.next (  ) ; 
         String key=atributo.getID (  ) ; 
         htable.put ( key, ( String ) atributo.get (  )  ) ;         
        }              
      } catch ( NamingException e )  {  
       System.out.println ( e.getMessage (  )  ) ;   
      } finally {  
       return htable; 
      }      
    } 


Attributes getAttributes(String name,
                         String[] attrIds)
                         throws NamingException
See Also:
getAttributes(Name, String[])
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Attributes getAttributes(Name name)
                         throws NamingException
See Also:
getAttributes(Name, String[]), getAttributes(String)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


Attributes getAttributes(Name name,
                         String[] attrIds)
                         throws NamingException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


DirContext getSchema(String name)
                     throws NamingException
See Also:
OperationNotSupportedException, getSchema(Name)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


DirContext getSchema(Name name)
                     throws NamingException
See Also:
OperationNotSupportedException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


DirContext getSchemaClassDefinition(String name)
                                    throws NamingException
See Also:
OperationNotSupportedException, getSchemaClassDefinition(Name)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


DirContext getSchemaClassDefinition(Name name)
                                    throws NamingException
See Also:
OperationNotSupportedException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void modifyAttributes(String name,
                      int mod_op,
                      Attributes attrs)
                      throws NamingException
See Also:
AttributeModificationException, modifyAttributes(Name, int, Attributes)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1168]Modify a LDAP entry
By rodrigo { at } cti { dot } inf { dot } br on 2004/12/03 08:16:22  Rate
/* 
  * Criado em 03/12/2004 
  * 
  * Para alterar o gabarito para este arquivo gerado v?? para 
  * Janela>Prefer??ncias>Java>Gera????o de C??digos>C??digo e Coment??rios 
  */
 
  
  
 /** 
  * @author rlacerda 
  * 
  * Para alterar o gabarito para este coment??rio do tipo gerado v?? para 
  * Janela>Prefer??ncias>Java>Gera????o de C??digos>C??digo e Coment??rios 
  */
 
 import javax.naming.*; 
 import javax.naming.directory.*; 
 import java.util.Hashtable; 
  
  
 class Altera  {  
   public static void main ( String [  ]  args )   {  
     // Identificando o provedor do servi??o 
     Hashtable env = new Hashtable ( 11 ) ; 
     env.put ( Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory" ) ; 
     // Identificando o servidor 
     env.put ( Context.PROVIDER_URL, "ldap://10.17.11.226:389" ) ; 
     // Estabelecendo as credenciais 
     env.put ( Context.SECURITY_AUTHENTICATION, "simple" ) ; 
     env.put ( Context.SECURITY_PRINCIPAL, "cn=root" ) ; 
     env.put ( Context.SECURITY_CREDENTIALS, "12345" ) ; 
     try  {  
       // Cria o contexto inicial 
       DirContext ctx = new InitialDirContext ( env ) ; 
       String name = "uid=mickey,cn=users,dc=sp,dc=gov,dc=br"; 
  
  
       // Especifica as mudancas a serem feitas 
        ModificationItem [  ]  mods = new ModificationItem [ 1 ] ; 
        // Alteracao da senha 
       mods [ 0 ]  = new ModificationItem ( DirContext.REPLACE_ATTRIBUTE, new BasicAttribute ( "rg", "25905993" )  ) ; 
       // Executa as modificacoes 
       ctx.modifyAttributes ( name, mods ) ; 
  
  
       // Fecha o contexto 
       ctx.close (  ) ; 
      }  catch  ( NamingException e )   {  
       System.err.println ( e.getMessage (  )  ) ; 
      }  
    }  
  }  
  
  
 


void modifyAttributes(String name,
                      ModificationItem[] mods)
                      throws NamingException
See Also:
AttributeModificationException, modifyAttributes(Name, ModificationItem[])
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void modifyAttributes(Name name,
                      int mod_op,
                      Attributes attrs)
                      throws NamingException
See Also:
modifyAttributes(Name, ModificationItem[]), AttributeModificationException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void modifyAttributes(Name name,
                      ModificationItem[] mods)
                      throws NamingException
See Also:
modifyAttributes(Name, int, Attributes), AttributeModificationException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void rebind(String name,
            Object obj,
            Attributes attrs)
            throws NamingException
See Also:
InvalidAttributesException, rebind(Name, Object, Attributes)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


void rebind(Name name,
            Object obj,
            Attributes attrs)
            throws NamingException
See Also:
bind(Name, Object, Attributes), Context.bind(Name, Object), InvalidAttributesException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final int REMOVE_ATTRIBUTE
See Also:
modifyAttributes(javax.naming.Name, int, javax.naming.directory.Attributes), ModificationItem
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


static final int REPLACE_ATTRIBUTE
See Also:
modifyAttributes(javax.naming.Name, int, javax.naming.directory.Attributes), ModificationItem
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


NamingEnumeration<SearchResult> search(String name,
                                       String filterExpr,
                                       Object[] filterArgs,
                                       SearchControls cons)
                                       throws NamingException
See Also:
InvalidSearchFilterException, InvalidSearchControlsException, ArrayIndexOutOfBoundsException, search(Name, String, Object[], SearchControls)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


NamingEnumeration<SearchResult> search(String name,
                                       String filter,
                                       SearchControls cons)
                                       throws NamingException
See Also:
InvalidSearchControlsException, InvalidSearchFilterException, search(Name, String, SearchControls)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


NamingEnumeration<SearchResult> search(String name,
                                       Attributes matchingAttributes)
                                       throws NamingException
See Also:
search(Name, Attributes)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


NamingEnumeration<SearchResult> search(String name,
                                       Attributes matchingAttributes,
                                       String[] attributesToReturn)
                                       throws NamingException
See Also:
search(Name, Attributes, String[])
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


NamingEnumeration<SearchResult> search(Name name,
                                       String filterExpr,
                                       Object[] filterArgs,
                                       SearchControls cons)
                                       throws NamingException
See Also:
MessageFormat, search(Name, Attributes, String[]), InvalidSearchFilterException, InvalidSearchControlsException, ArrayIndexOutOfBoundsException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


NamingEnumeration<SearchResult> search(Name name,
                                       String filter,
                                       SearchControls cons)
                                       throws NamingException
See Also:
search(Name, String, Object[], SearchControls), InvalidSearchControlsException, InvalidSearchFilterException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


NamingEnumeration<SearchResult> search(Name name,
                                       Attributes matchingAttributes)
                                       throws NamingException
See Also:
search(Name, Attributes, String[])
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


NamingEnumeration<SearchResult> search(Name name,
                                       Attributes matchingAttributes,
                                       String[] attributesToReturn)
                                       throws NamingException
See Also:
search(Name, String, Object[], SearchControls), SearchControls
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags