#include #include #include #include #define TOKEN_RESYNC_EXOP_REQUEST_OID "2.16.840.1.113730.3.6.9" #define TOKEN_RESYNC_TAG_TOKEN_DN 0x80U #define TOKEN_RESYNC_TAG_FIRST_FACTOR 0x81U int main( int argc, char **argv) { struct berval *req_data = NULL, *result_data = NULL; BerElement *ber; char *userDN = "uid=mark"; char *tokenDN = "cn=token"; char *host = "localhost.localdomain"; char *oidresult = NULL; int port = 389; int first = 1; int second = 2; int msgid = 0; int version = LDAP_VERSION3; int result = 0; int rc = 0; LDAP *ld; ber = der_alloc(); /* in this example, we are jsut sending the token, and not the password(firstFactor) */ ber_printf(ber , "{stsii}", userDN, TOKEN_RESYNC_TAG_TOKEN_DN, tokenDN,first, second); if (ber_flatten(ber, &req_data) == -1){ printf("Failed to flatten\n"); return 1; } ber_free(ber, 1); ld = ldap_init(host, port); if(ld == NULL){ printf("ldap_init failed\n"); return 1; } ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); printf("Sending extended op...\n"); rc = ldap_extended_operation_s(ld, TOKEN_RESYNC_EXOP_REQUEST_OID, req_data, NULL, NULL /* clientctls */, &oidresult, &result_data); printf("Extended opi result: %d\n",rc); ldap_unbind(ld); return 0; }