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

View File

@ -346,6 +346,7 @@ typedef struct ldapcontrol {
#define LDAP_CONTROL_X_TREE_DELETE "1.2.840.113556.1.4.805"
/* 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_SHOW_DELETED "1.2.840.113556.1.4.417"
#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 ));
#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
*/

View File

@ -260,3 +260,21 @@ ldap_create_extended_dn_control(
}
#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 */