Package org.apache.directory.shared.ldap.entry

Examples of org.apache.directory.shared.ldap.entry.Entry


    {
        LdapConnection connection = getAdminConnection( ldapServer );

        AddResponse resp = createSubContext( "ou", "blah");
        resp = createSubContext( new DN( "ou=blah,ou=system" ), "ou", "subctx");
        Entry entry = ( ( SearchResultEntry ) connection.lookup( "ou=subctx,ou=blah,ou=system" ) ).getEntry();
        assertNotNull( entry );
    }
View Full Code Here


    {
        LdapConnection connection = getAdminConnection( ldapServer );

        AddResponse resp = createSubContext( "ou", "blah" );

        Entry entry = ( ( SearchResultEntry ) connection.lookup( "ou=blah,ou=system" ) ).getEntry();
        assertNotNull( entry );
        connection.delete( entry.getDn() );

        Object respEntry = connection.lookup( entry.getDn().getName() );
        assertNull( respEntry );
    }
View Full Code Here

     * it exists already
     */
    public static DN createGroup( String cn, String firstMemberDn ) throws Exception
    {
        DN groupDN = new DN( "cn=" + cn + ",ou=groups,ou=system" );
        Entry entry = new DefaultClientEntry( groupDN );
        entry.add( SchemaConstants.OBJECT_CLASS_AT, "groupOfUniqueNames" );
        entry.add( SchemaConstants.UNIQUE_MEMBER_AT, firstMemberDn );
        entry.add( SchemaConstants.CN_AT, cn );

        getAdminConnection().add( entry );
        return groupDN;
    }
View Full Code Here

     */
    public static DN createUser( String uid, String password ) throws Exception
    {
        LdapConnection connection = getAdminConnection();

        Entry entry = new DefaultClientEntry( new DN( "uid=" + uid + ",ou=users,ou=system" ) );
        entry.add( SchemaConstants.UID_AT, uid );
        entry.add( SchemaConstants.OBJECT_CLASS_AT, "person", "organizationalPerson", "inetOrgPerson" );
        entry.add( SchemaConstants.SN_AT, uid );
        entry.add( SchemaConstants.CN_AT, uid );
        entry.add( SchemaConstants.USER_PASSWORD_AT, password );

        connection.add( entry );

        return entry.getDn();
    }
View Full Code Here

     */
    public static DN createGroup( String groupName ) throws Exception
    {
        DN groupDN = new DN( "cn=" + groupName + ",ou=groups,ou=system" );

        Entry entry = new DefaultClientEntry( groupDN );
        entry.add( SchemaConstants.OBJECT_CLASS_AT, "groupOfUniqueNames" );
        // TODO might be ServerDNConstants.ADMIN_SYSTEM_DN_NORMALIZED
        entry.add( SchemaConstants.UNIQUE_MEMBER_AT, "uid=admin, ou=system" );
        entry.add( SchemaConstants.CN_AT, groupName );

        getAdminConnection().add( entry );

        return groupDN;
    }
View Full Code Here

    public static ResultCodeEnum createAccessControlSubentry( String cn, String subtree, String aciItem )
        throws Exception
    {
        LdapConnection connection = getAdminConnection();

        Entry systemEntry = ( ( SearchResultEntry ) connection.lookup( ServerDNConstants.SYSTEM_DN, "+", "*" ) )
            .getEntry();

        // modify ou=system to be an AP for an A/C AA if it is not already
        EntryAttribute administrativeRole = systemEntry.get( "administrativeRole" );
       
        if ( administrativeRole == null || !administrativeRole.contains( SubentryInterceptor.AC_AREA ) )
        {
            ModifyRequest modReq = new ModifyRequest( systemEntry.getDn() );
            modReq.add( "administrativeRole", SubentryInterceptor.AC_AREA );
            connection.modify( modReq );
        }

        // now add the A/C subentry below ou=system
        Entry subEntry = new DefaultClientEntry( new DN( "cn=" + cn + "," + ServerDNConstants.SYSTEM_DN ) );
        subEntry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.SUBENTRY_OC,
            SchemaConstants.ACCESS_CONTROL_SUBENTRY_OC );
        subEntry.add( SchemaConstants.SUBTREE_SPECIFICATION_AT, subtree );
        subEntry.add( SchemaConstants.PRESCRIPTIVE_ACI_AT, aciItem );

        AddResponse addResp = connection.add( subEntry );

        return addResp.getLdapResult().getResultCode();
    }
View Full Code Here

        try
        {
            DN userName = new DN( "uid=" + uid + ",ou=users,ou=system" );
            LdapConnection connection = getConnectionAs( userName, password );

            Entry entry = new DefaultClientEntry( new DN( "ou=testou,ou=system" ) );
            entry.add( SchemaConstants.OU_AT, "testou" );
            entry.add( SchemaConstants.OBJECT_CLASS_AT, "organizationalUnit" );
           
            AddResponse resp = connection.add( entry );
           
            if( resp.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS )
            {
                return false;
            }

            connection.delete( entry.getDn() );
            connection.close();
           
            return true;
        }
        catch ( LdapException e )
View Full Code Here

    {
        DN entryDN = new DN( entryRdn + ",ou=system" );
        boolean result;
       
        // create the entry with the telephoneNumber attribute to compare
        Entry testEntry = new DefaultClientEntry( entryDN );
        testEntry.add( SchemaConstants.OBJECT_CLASS_AT, "organizationalUnit" );
        testEntry.add( SchemaConstants.OU_AT, "testou" );
        testEntry.add( "telephoneNumber", "867-5309" ); // jenny don't change your number

        LdapConnection adminConnection = getAdminConnection();

        // create the entry as admin
        adminConnection.add( testEntry );
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

    {
        StringReader strIn = new StringReader( text );
        BufferedReader in = new BufferedReader( strIn );

        String line = null;
        Entry entry = new DefaultClientEntry();

        try
        {
            while ( ( line = in.readLine() ) != null )
            {
                if ( line.length() == 0 )
                {
                    continue;
                }

                String addedLine = line.trim();

                if ( StringTools.isEmpty( addedLine ) )
                {
                    continue;
                }

                EntryAttribute attribute = LdifReader.parseAttributeValue( addedLine );
                EntryAttribute oldAttribute = entry.get( attribute.getId() );

                if ( oldAttribute != null )
                {
                    try
                    {
                        oldAttribute.add( attribute.get() );
                        entry.put( oldAttribute );
                    }
                    catch ( LdapException ne )
                    {
                        // Do nothing
                    }
                }
                else
                {
                    try
                    {
                        entry.put( attribute );
                    }
                    catch ( LdapException ne )
                    {
                        // TODO do nothing ...
                    }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.entry.Entry

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.