Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 312926 Details for
Bug 428232
DN Rename with case change only fails
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
test program modrdn.c
modrdn.c (text/plain), 7.00 KB, created by
Noriko Hosoi
on 2008-07-29 19:44:47 UTC
(
hide
)
Description:
test program modrdn.c
Filename:
MIME Type:
Creator:
Noriko Hosoi
Created:
2008-07-29 19:44:47 UTC
Size:
7.00 KB
patch
obsolete
>/* ***** BEGIN LICENSE BLOCK ***** > * Version: MPL 1.1/GPL 2.0/LGPL 2.1 > * > * The contents of this file are subject to the Mozilla Public License Version > * 1.1 (the "License"); you may not use this file except in compliance with > * the License. You may obtain a copy of the License at > * http://www.mozilla.org/MPL/ > * > * Software distributed under the License is distributed on an "AS IS" basis, > * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License > * for the specific language governing rights and limitations under the > * License. > * > * The Original Code is Mozilla Communicator client code, released > * March 31, 1998. > * > * The Initial Developer of the Original Code is > * Netscape Communications Corporation. > * Portions created by the Initial Developer are Copyright (C) 1998-1999 > * the Initial Developer. All Rights Reserved. > * > * Contributor(s): > * > * Alternatively, the contents of this file may be used under the terms of > * either of the GNU General Public License Version 2 or later (the "GPL"), > * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), > * in which case the provisions of the GPL or the LGPL are applicable instead > * of those above. If you wish to allow use of your version of this file only > * under the terms of either the GPL or the LGPL, and not to allow others to > * use your version of this file under the terms of the MPL, indicate your > * decision by deleting the provisions above and replace them with the notice > * and other provisions required by the GPL or the LGPL. If you do not delete > * the provisions above, a recipient may use your version of this file under > * the terms of any one of the MPL, the GPL or the LGPL. > * > * ***** END LICENSE BLOCK ***** */ > >/* > * Modify the RDN (relative distinguished name) of an entry. In this > * example, we change the dn "cn=Jacques Smith,ou=People,dc=example,dc=com > * to "cn=Jacques M Smith,ou=People,dc=example,dc=com. > * > * Since it is an error to either (1) attempt to modrdn an entry which > * does not exist, or (2) modrdn an entry where the destination name > * already exists, we take some steps, for this example, to make sure > * we'll succeed. We (1) add "cn=Jacques Smith" (if the entry exists, > * we just ignore the error, and (2) delete "cn=Jacques M Smith" (if the > * entry doesn't exist, we ignore the error). > * > * We pass 0 for the "deleteoldrdn" argument to ldap_modrdn2_s(). This > * means that after we change the RDN, the server will put the value > * "Jacques Smith" into the cn attribute of the new entry, in addition to > * "Jacques M Smith". > */ > >#include "examples.h" > >#define NMODS 4 > >unsigned long global_counter = 0; > >static void free_mods( LDAPMod **mods ); > >#undef MY_PORT >#undef MGR_DN >#undef MGR_PW >#define MY_PORT 389 >#define MGR_DN "cn=Directory Manager" >#define MGR_PW "password" > >int >main( int argc, char **argv ) >{ > LDAP *ld; > char *dn, *ndn, *nrdn, *founddn = NULL; > int i; > int rc; > LDAPMod **mods; > LDAPMessage *result, *e; > > int my_port = MY_PORT; > char *mgr_pw = MGR_PW; > > if (argc > 1) { > if (0 == strcmp(argv[1], "-h")) { > fprintf(stderr, > "Usage: %s [<port> [<directory_manager_password>]]\n", argv[0]); > exit(0); > } > > my_port = atoi(argv[1]); > if (argc > 2) { > mgr_pw = argv[2]; > } > } > > /* Values we'll use in creating the entry */ > char *objectclass_values[] = { "top", "person", "organizationalPerson", > "inetOrgPerson", NULL }; > char *cn_values[] = { "Jacques Smith", NULL }; > char *sn_values[] = { "Smith", NULL }; > char *givenname_values[] = { "Jacques", NULL }; > > /* Specify the DN we're adding */ > dn = "cn=Jacques Smith, " MY_SEARCHBASE; /* see examples.h */ > /* the destination DN */ > ndn = "cn=Jacques SMITH, " MY_SEARCHBASE; /* see examples.h */ > /* the new RDN */ > nrdn = "cn=Jacques SMITH"; > > /* get a handle to an LDAP connection */ > if ( (ld = ldap_init( MY_HOST, my_port )) == NULL ) { > perror( "ldap_init" ); > return( 1 ); > } > /* authenticate to the directory as the Directory Manager */ > if ( ldap_simple_bind_s( ld, MGR_DN, mgr_pw ) != LDAP_SUCCESS ) { > ldap_perror( ld, "ldap_simple_bind_s" ); > return( 1 ); > } > > if (( mods = ( LDAPMod ** ) malloc(( NMODS + 1 ) * sizeof( LDAPMod *))) > == NULL ) { > fprintf( stderr, "Cannot allocate memory for mods array\n" ); > return( 1 ); > } > /* Construct the array of values to add */ > for ( i = 0; i < NMODS; i++ ) { > if (( mods[ i ] = ( LDAPMod * ) malloc( sizeof( LDAPMod ))) == NULL ) { > fprintf( stderr, "Cannot allocate memory for mods element\n" ); > return( 1 ); > } > } > mods[ 0 ]->mod_op = 0; > mods[ 0 ]->mod_type = "objectclass"; > mods[ 0 ]->mod_values = objectclass_values; > mods[ 1 ]->mod_op = 0; > mods[ 1 ]->mod_type = "cn"; > mods[ 1 ]->mod_values = cn_values; > mods[ 2 ]->mod_op = 0; > mods[ 2 ]->mod_type = "sn"; > mods[ 2 ]->mod_values = sn_values; > mods[ 3 ]->mod_op = 0; > mods[ 3 ]->mod_type = "givenname"; > mods[ 3 ]->mod_values = givenname_values; > mods[ 4 ] = NULL; > > > /* Add the entry */ > if (( rc = ldap_add_s( ld, dn, mods )) != LDAP_SUCCESS ) { > /* If entry exists already, fine. Ignore this error. */ > if ( rc == LDAP_ALREADY_EXISTS ) { > /* search for all entries with surname of Jensen */ > if ( ldap_search_s( ld, dn, LDAP_SCOPE_BASE, > "(cn=*)", NULL, 0, &result ) != LDAP_SUCCESS ) { > ldap_perror( ld, "ldap_search_s" ); > if ( result == NULL ) { > ldap_unbind( ld ); > return( 1 ); > } > } > e = ldap_first_entry( ld, result ); > if (NULL != e) { > founddn = ldap_get_dn( ld, e ); > } else { > printf( "Expected entry was not found\n" ); > } > ldap_msgfree( result ); > if (NULL == founddn) { > printf( "Expected entry was not found\n" ); > } else { > printf( "Entry \"%s is already in the directory.\n", founddn ); > } > } else { > ldap_perror( ld, "ldap_add_s" ); > free_mods( mods ); > return( 1 ); > } > } else { > printf( "Added entry \"%s\".\n", dn ); > } > free_mods( mods ); > >#if 0 > /* Delete the destination entry, for this example */ > if (( rc = ldap_delete_s( ld, ndn )) != LDAP_SUCCESS ) { > /* If entry does not exist, fine. Ignore this error. */ > if ( rc == LDAP_NO_SUCH_OBJECT ) { > printf( "Entry \"%s\" is not in the directory. " > "No need to delete.\n", ndn ); > } else { > ldap_perror( ld, "ldap_delete_s" ); > return( 1 ); > } > } else { > printf( "Deleted entry \"%s\".\n", ndn ); > } >#endif > > /* Do the modrdn operation */ > printf("Calling modrdn: \"%s\" => \"%s\"\n", founddn?founddn:dn, nrdn); > if ( ldap_modrdn2_s( ld, founddn?founddn:dn, nrdn, 0 ) != LDAP_SUCCESS ) { > ldap_perror( ld, "ldap_modrdn2_s" ); > return( 1 ); > } > > printf( "The modrdn operation was successful. Entry\n" > "\"%s\" has been changed to\n" > "\"%s\".\n", founddn?founddn:dn, ndn ); > > ldap_unbind( ld ); > return 0; >} > > > >/* > * Free a mods array. > */ >static void >free_mods( LDAPMod **mods ) >{ > int i; > > for ( i = 0; i < NMODS; i++ ) { > free( mods[ i ] ); > } > free( mods ); >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 428232
:
312887
|
312890
|
312925
| 312926 |
312931
|
312932