Package org.apache.directory.shared.ldap.ldif

Examples of org.apache.directory.shared.ldap.ldif.LdifEntry


    @Test
    public void testListUsersAsAdmin() throws Exception
    {
        LdapContext sysRoot = getSystemContext( service );
        HashSet<String> set = new HashSet<String>();
        LdifEntry akarasulu = getUserAddLdif();
        service.getAdminSession().add(
            new DefaultServerEntry( service.getSchemaManager(), akarasulu.getEntry() ) );
               

        NamingEnumeration<NameClassPair> list = sysRoot.list( "ou=users" );
       
        while ( list.hasMore() )
View Full Code Here


        String ref0 = "ldap://fermi:10389/ou=users,ou=system";
        String ref1 = "ldap://hertz:10389/ou=users,dc=example,dc=com";
        String ref2 = "ldap://maxwell:10389/ou=users,ou=system";
        td.rootCtx = getSystemContext( service );

        LdifEntry akarasulu = getUserAddLdif();
        service.getAdminSession().add(
            new DefaultServerEntry( service.getSchemaManager(), akarasulu.getEntry() ), true );

        // -------------------------------------------------------------------
        // Adds a referral entry regardless of referral handling settings
        // -------------------------------------------------------------------
View Full Code Here

{

    @Test
    public void testObjectFactory() throws Exception
    {
        LdifEntry akarasulu = getUserAddLdif();
        service.getAdminSession().add(
            new DefaultServerEntry( service.getSchemaManager(), akarasulu.getEntry() ) );


        LdapContext sysRoot = getSystemContext( service );
        sysRoot.addToEnvironment( Context.OBJECT_FACTORIES, PersonObjectFactory.class.getName() );
        Object obj = sysRoot.lookup( "uid=akarasulu, ou=users" );
View Full Code Here

     *
     * @throws NamingException on error
     */
    protected void createData() throws Exception
    {
        LdifEntry akarasulu = getUserAddLdif();
        service.getAdminSession().add(
            new DefaultServerEntry( service.getSchemaManager(), akarasulu.getEntry() ) );

        LdapContext sysRoot = getSystemContext( service );

        /*
         * create ou=testing00,ou=system
View Full Code Here

        systemDn.normalize( oidsMap );
       
        DN adminDn = new DN( "uid=admin, ou=system" );
        adminDn.normalize( oidsMap );

        LdifEntry forward = new LdifEntry();
        forward.setDn( systemDn );
        forward.setChangeType( ChangeType.Add );
        forward.putAttribute( "objectClass", "organizationalUnit" );
        forward.putAttribute( "ou", "system" );
       
        DN reverseDn = new DN( forward.getDn() );
        reverseDn.normalize( oidsMap );

        LdifEntry reverse = LdifRevertor.reverseAdd( reverseDn );

        String zuluTime = DateUtils.getGeneralizedTime();
        long revision = 1L;
       
        LdapPrincipal principal = new LdapPrincipal( adminDn, AuthenticationLevel.SIMPLE, StringTools.getBytesUtf8( "secret"  ) );
View Full Code Here

    @Test
    public void testLogCheckRevision() throws Exception
    {
        assertEquals( "first revision is always 0", 0, store.getCurrentRevision() );

        LdifEntry forward = new LdifEntry();
        forward.setDn( "ou=system" );
        forward.setChangeType( ChangeType.Add );
        forward.putAttribute( "objectClass", "organizationalUnit" );
        forward.putAttribute( "ou", "system" );

        LdifEntry reverse = LdifRevertor.reverseAdd( new DN( forward.getDn() ) );
        assertEquals( 1, store.log( new LdapPrincipal(), forward, reverse ).getRevision() );
        assertEquals( 1, store.getCurrentRevision() );
    }
View Full Code Here

     * @throws NamingException on error
     */
    @Test
    public void testConfirmNonAdminUserDnIsCreatorsName() throws Exception
    {
        LdifEntry akarasulu = getUserAddLdif();
        service.getAdminSession().add(
            new DefaultServerEntry( service.getSchemaManager(), akarasulu.getEntry() ) );

        LdapContext sysRoot = getSystemContext( service );
        createData( sysRoot );

        Attributes attributes = sysRoot.getAttributes( "uid=akarasulu,ou=users", new String[]
View Full Code Here

    public static LdifEntry getUserAddLdif( String dnstr, byte[] password, String cn, String sn )
            throws LdapException
    {
        DN dn = new DN( dnstr );
        LdifEntry ldif = new LdifEntry();
        ldif.setDn( dnstr );
        ldif.setChangeType( ChangeType.Add );

        EntryAttribute attr = new DefaultClientAttribute( "objectClass",
            "top", "person", "organizationalPerson", "inetOrgPerson" );
        ldif.addAttribute( attr );

        attr = new DefaultClientAttribute( "ou", "Engineering", "People" );
        ldif.addAttribute( attr );

        String uid = ( String ) dn.getRdn().getNormValue();
        ldif.putAttribute( "uid", uid );

        ldif.putAttribute( "l", "Bogusville" );
        ldif.putAttribute( "cn", cn );
        ldif.putAttribute( "sn", sn );
        ldif.putAttribute( "mail", uid + "@apache.org" );
        ldif.putAttribute( "telephoneNumber", "+1 408 555 4798" );
        ldif.putAttribute( "facsimileTelephoneNumber", "+1 408 555 9751" );
        ldif.putAttribute( "roomnumber", "4612" );
        ldif.putAttribute( "userPassword", password );

        String givenName = cn.split( " " )[0];
        ldif.putAttribute( "givenName", givenName );
        return ldif;
    }
View Full Code Here

    {
        for ( LdifEntry testEntry : testEntries )
        {
            try
            {
                LdifEntry ldifEntry = testEntry.clone();
                Entry entry = ldifEntry.getEntry();
                String dn = ldifEntry.getDn().getName();

                try
                {
                    getAdminSession().add( new DefaultServerEntry( schemaManager, entry ) );
                }
View Full Code Here

                List<LdifEntry> entries = ldifReader.parseLdifFile( ldifFile.getAbsolutePath() );

                if ( entries != null && !entries.isEmpty() )
                {
                    // this ldif will have only one entry
                    LdifEntry ldifEntry = entries.get( 0 );
                    LOG.debug( "adding entry {}", ldifEntry );

                    ServerEntry serverEntry = new DefaultServerEntry( schemaManager, ldifEntry.getEntry() );

                    // call add on the wrapped store not on the self 
                    wrappedStore.add( serverEntry );
                }
            }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.ldif.LdifEntry

Copyright © 2018 www.massapicom. 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.