Add MS AD persistent search ctrl

This commit is contained in:
Howard Chu 2018-12-13 05:44:46 -08:00
parent 6081a0307c
commit 18e0bcb7de
3 changed files with 67 additions and 1 deletions

View File

@ -148,6 +148,9 @@ usage( void )
#endif #endif
#ifdef LDAP_CONTROL_X_SHOW_DELETED #ifdef LDAP_CONTROL_X_SHOW_DELETED
fprintf( stderr, _(" [!]showDeleted (MS AD Show Deleted)\n")); fprintf( stderr, _(" [!]showDeleted (MS AD Show Deleted)\n"));
#endif
#ifdef LDAP_CONTROL_X_SERVER_NOTIFICATION
fprintf( stderr, _(" [!]serverNotif (MS AD Server Notification)\n"));
#endif #endif
fprintf( stderr, _(" [!]<oid>[=:<b64value>] (generic control; no response handling)\n")); fprintf( stderr, _(" [!]<oid>[=:<b64value>] (generic control; no response handling)\n"));
fprintf( stderr, _(" -f file read operations from `file'\n")); fprintf( stderr, _(" -f file read operations from `file'\n"));
@ -271,6 +274,10 @@ static int extendedDnFlag;
static int showDeleted; static int showDeleted;
#endif #endif
#ifdef LDAP_CONTROL_X_SERVER_NOTIFICATION
static int serverNotif;
#endif
static int static int
ctrl_add( void ) ctrl_add( void )
{ {
@ -698,7 +705,7 @@ handle_private_option( int i )
} }
*cookiep = '\0'; *cookiep = '\0';
} }
num = sscanf( cvalue, "%d", &tmp ); num = sscanf( cvalue, "%i", &tmp );
if ( num != 1 ) { if ( num != 1 ) {
fprintf( stderr, fprintf( stderr,
_("Invalid value for dirSync, %s.\n"), _("Invalid value for dirSync, %s.\n"),
@ -760,6 +767,23 @@ handle_private_option( int i )
showDeleted = 1 + crit; showDeleted = 1 + crit;
#endif /* LDAP_CONTROL_X_SHOW_DELETED */ #endif /* LDAP_CONTROL_X_SHOW_DELETED */
#ifdef LDAP_CONTROL_X_SERVER_NOTIFICATION
} else if ( strcasecmp( control, "serverNotif" ) == 0 ) {
int num, tmp;
if( serverNotif ) {
fprintf( stderr,
_("serverNotif control previously specified\n"));
exit( EXIT_FAILURE );
}
if ( cvalue != NULL ) {
fprintf( stderr,
_("serverNotif: no control value expected\n") );
usage();
}
serverNotif = 1 + crit;
#endif /* LDAP_CONTROL_X_SERVER_NOTIFICATION */
} else if ( tool_is_oid( control ) ) { } else if ( tool_is_oid( control ) ) {
if ( c != NULL ) { if ( c != NULL ) {
int i; int i;
@ -1067,6 +1091,9 @@ getNextPage:
#endif #endif
#ifdef LDAP_CONTROL_X_SHOW_DELETED #ifdef LDAP_CONTROL_X_SHOW_DELETED
|| showDeleted || showDeleted
#endif
#ifdef LDAP_CONTROL_X_SERVER_NOTIFICATION
|| serverNotif
#endif #endif
|| domainScope || domainScope
|| pagedResults || pagedResults
@ -1313,6 +1340,19 @@ getNextPage:
c[i].ldctl_iscritical = showDeleted > 1; c[i].ldctl_iscritical = showDeleted > 1;
i++; i++;
} }
#endif
#ifdef LDAP_CONTROL_X_SERVER_NOTIFICATION
if ( serverNotif ) {
if ( ctrl_add() ) {
tool_exit( ld, EXIT_FAILURE );
}
c[i].ldctl_oid = LDAP_CONTROL_X_SERVER_NOTIFICATION;
c[i].ldctl_value.bv_val = NULL;
c[i].ldctl_value.bv_len = 0;
c[i].ldctl_iscritical = serverNotif > 1;
i++;
}
#endif #endif
} }

View File

@ -346,6 +346,7 @@ typedef struct ldapcontrol {
#define LDAP_CONTROL_X_TREE_DELETE "1.2.840.113556.1.4.805" #define LDAP_CONTROL_X_TREE_DELETE "1.2.840.113556.1.4.805"
/* MS Active Directory controls - not implemented in slapd(8) */ /* MS Active Directory controls - not implemented in slapd(8) */
#define LDAP_CONTROL_X_SERVER_NOTIFICATION "1.2.840.113556.1.4.528"
#define LDAP_CONTROL_X_EXTENDED_DN "1.2.840.113556.1.4.529" #define LDAP_CONTROL_X_EXTENDED_DN "1.2.840.113556.1.4.529"
#define LDAP_CONTROL_X_SHOW_DELETED "1.2.840.113556.1.4.417" #define LDAP_CONTROL_X_SHOW_DELETED "1.2.840.113556.1.4.417"
#define LDAP_CONTROL_X_DIRSYNC "1.2.840.113556.1.4.841" #define LDAP_CONTROL_X_DIRSYNC "1.2.840.113556.1.4.841"
@ -2604,6 +2605,13 @@ ldap_create_show_deleted_control LDAP_P((
LDAPControl **ctrlp )); LDAPControl **ctrlp ));
#endif /* LDAP_CONTROL_X_SHOW_DELETED */ #endif /* LDAP_CONTROL_X_SHOW_DELETED */
#ifdef LDAP_CONTROL_X_SERVER_NOTIFICATION
LDAP_F( int )
ldap_create_server_notification_control LDAP_P((
LDAP *ld,
LDAPControl **ctrlp ));
#endif /* LDAP_CONTROL_X_SERVER_NOTIFICATION */
/* /*
* in assertion.c * in assertion.c
*/ */

View File

@ -260,3 +260,21 @@ ldap_create_extended_dn_control(
} }
#endif /* LDAP_CONTROL_X_EXTENDED_DN */ #endif /* LDAP_CONTROL_X_EXTENDED_DN */
#ifdef LDAP_CONTROL_X_SERVER_NOTIFICATION
int
ldap_create_sever_notification_control( LDAP *ld,
LDAPControl **ctrlp )
{
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
assert( ctrlp != NULL );
ld->ld_errno = ldap_control_create( LDAP_CONTROL_X_SERVER_NOTIFICATION,
0, NULL, 0, ctrlp );
return ld->ld_errno;
}
#endif /* LDAP_CONTROL_X_SERVER_NOTIFICATION */