]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
Add MS AD persistent search ctrl
authorHoward Chu <hyc@openldap.org>
Thu, 13 Dec 2018 13:44:46 +0000 (05:44 -0800)
committerHoward Chu <hyc@openldap.org>
Thu, 13 Dec 2018 13:44:46 +0000 (05:44 -0800)
clients/tools/ldapsearch.c
include/ldap.h
libraries/libldap/msctrl.c

index 7d8ab86b027a133fd40589cad2ca22fa06f9b945..96cc505a4ecb84df9b0904bd34daa3b20f81f9e2 100644 (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
        }
 
index c58c576d3ae0a3bf6ce46c2d672b6f13eff36296..d32207f7f95a7f9e37d39d759ac493452a768724 100644 (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
  */
index 2137cc962846f52cdcf2a4550cb9e0a218c69414..aa6a39c4cb0c12b57d0d734fec9764846fb4ac9c 100644 (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 */