1N/A * the License at http://www.mozilla.org/NPL/
1N/A/* ldapsearch.c - generic program to search LDAP */
1N/A#include "ldaptool.h"
1N/A#ifdef SOLARIS_LDAP_CMD
1N/A#include "solaris-int.h"
1N/A#ifndef SOLARIS_LDAP_CMD
1N/A unsigned long ldifoptions );
1N/A#ifdef SOLARIS_LDAP_CMD
1N/Astatic void fill_ldapsearch_msgtypes( void );
1N/A fprintf( stderr, gettext("usage: %s -b basedn [options] filter [attributes...]\n"), ldaptool_progname );
1N/A fprintf( stderr, gettext(" %s -b basedn [options] -f file [attributes...]\nwhere:\n"), ldaptool_progname );
1N/A fprintf( stderr, gettext(" file\tfile containing a sequence of LDAP search filters to use\n") );
1N/A fprintf( stderr, gettext(" attributes\twhitespace-separated list of attributes to retrieve\n") );
1N/A ldaptool_common_usage( 0 );
1N/A#ifndef HAVE_SASL_OPTIONS
1N/A fprintf( stderr, gettext(" -1\t\tomit leading \"version: %d\" line in LDIF output\n"), LDIF_VERSION_ONE );
1N/A fprintf( stderr, gettext(" -B\t\tprint non-ASCII values and use old output format (attr=value)\n") );
1N/A#ifdef SOLARIS_LDAP_CMD
1N/A fprintf( stderr, gettext(" -F sep\tprint `sep' instead of `%s' between attribute names\n"), LDAPTOOL_DEFSEP );
1N/A fprintf( stderr, gettext(" -a deref\tone of never, always, search, or find (default: never)\n") );
1N/A fprintf( stderr, gettext(" -l timelim\ttime limit (in seconds) for search (default is no limit)\n") );
1N/A fprintf( stderr, gettext(" -z sizelim\tsize limit (in entries) for search (default is no limit)\n") );
1N/A fprintf( stderr, gettext(" -G before%cafter%cindex%ccount | before%cafter%cvalue where 'before' and\n"), VLV_PARAM_SEP, VLV_PARAM_SEP, VLV_PARAM_SEP, VLV_PARAM_SEP, VLV_PARAM_SEP );
1N/A#ifndef SOLARIS_LDAP_CMD
1N/A fprintf( stderr, gettext("\t\t A value of \"\" means \"the authorization id for the operation\".\n"));
1N/A fprintf( stderr, gettext(" -X attrlist\tspecifies the getEffectiveRights control specific attribute list.\n"));
1N/A#ifndef SOLARIS_LDAP_CMD
1N/A#ifdef SOLARIS_LDAP_CMD
1N/A free_filtpattern = 0;
1N/A server_sort = 0;
1N/A#ifdef HAVE_SASL_OPTIONS
1N/A#ifdef SOLARIS_LDAP_CMD
1N/A 0, options_callback );
1N/A 0, options_callback );
1N/A 0, options_callback );
1N/A } else if ( server_sort ) {
1N/A if ( !ldaptool_not ) {
1N/A if ( ldaptool_verbose ) {
1N/A ++includeufn;
1N/A#ifdef SOLARIS_LDAP_CMD
1N/A#ifdef HAVE_SASL_OPTIONS
1N/A#ifdef HAVE_SASL_OPTIONS_2
1N/A ++allow_binary;
1N/A write_ldif_version = 0;
1N/A#ifndef SOLARIS_LDAP_CMD
1N/A use_psearch++;
1N/A#ifdef HAVE_SNPRINTF
1N/A if (mallocd_filter) {
1N/A mallocd_filter = 0;
1N/A if ( ldaptool_verbose ) {
1N/A if ( ldaptool_not ) {
1N/A return( LDAP_SUCCESS );
1N/A#ifndef SOLARIS_LDAP_CMD
1N/A if ( do_effective_rights_control ) {
1N/A if (use_psearch) {
1N/A if (server_sort) {
1N/A if ( ldaptool_verbose ) {
1N/A if ( ldaptool_verbose ) {
1N/A if ( ldaptool_verbose ) {
1N/A != LDAP_SUCCESS ) {
1N/A if (server_sort) {
1N/A if ( ldaptool_verbose ) {
1N/A printf(gettext("Server reported sorting error %ld: %s, attribute in error\"%s\"\n"),result,sortresult2string(result),attribute);
1N/A if ( LDAP_SUCCESS != ldap_parse_virtuallist_control(ld,ctrl_response_array,&vpos, &vcount,&vresult) ) {
1N/A if ( ldaptool_verbose ) {
1N/A if ( ldaptool_verbose ) {
1N/A if ( includeufn ) {
1N/A if ( use_psearch ) {
1N/A#ifdef SOLARIS_LDAP_CMD
1N/A if ( chgnumpresent ) {
1N/A#ifdef HAVE_SNPRINTF
1N/A "%s/ldapsearch-%s-XXXXXX",
1N/A ldaptool_get_tmp_dir(), a ) < 0 ) {
1N/A ldaptool_get_tmp_dir(), a );
1N/A if ( produce_file_urls ) {
1N/A ldap_memfree( a );
1N/A unsigned long ldifoptions )
1N/A if ( minimize_base64 ) {
1N/A#ifndef LDAP_REQ_BIND
1N/A#ifdef SOLARIS_LDAP_CMD
1N/A / sizeof(struct ldapsearch_type2str))
1N/A#ifdef SOLARIS_LDAP_CMD
1N/A#ifdef SOLARIS_LDAP_CMD
1N/A (void) fill_ldapsearch_msgtypes();
1N/A for ( i = 0; i < LDAPSEARCHTOOL_NUMTYPES; ++i ) {
1N/A case LDAP_CHANGETYPE_ADD:
1N/A case LDAP_CHANGETYPE_DELETE:
1N/A case LDAP_CHANGETYPE_MODIFY:
1N/A case LDAP_CHANGETYPE_MODDN: