Esempio n. 1
0
int main(int argc, char *argv[])
{
    LDAP *ld;
    int rc;
    uxds_bind_t sflag;
    uxds_authz_t auth;
    uxds_data_t mdata;
    char *bin = argv[0];
    sflag = parse_args(argc, argv, USER, MOD, 6, &auth, &mdata, bin);

#ifdef HAVE_LDAP_SASL_GSSAPI
    if ((auth.pkcert) && (argc < 8)) {
#else
    if (argc < 6) {
#endif		/* HAVE_LDAP_SASL_GSSAPI */
	if ((!mdata.exp) || (!mdata.cpw)) {
	    fprintf(stderr,
		    "At least ONE attribute must be selected to use lusermod.\n");
	    fprintf(stderr, "parse_args failed.\n");
	    exit(EXIT_FAILURE);
	}
    }

    /* initialize LDAP context */
    rc = ldap_initialize(&ld, auth.uri);
    if (rc != LDAP_SUCCESS) {
	fprintf(stderr, "Could not create LDAP session handle (%d): %s\n",
		rc, ldap_err2string(rc));
	exit(EXIT_FAILURE);
    }

    /* authenticate to directory service */
    if (uxds_user_authz(sflag, auth, ld) != 0) {
	fprintf(stderr, "uxds_user_authz failed.\n");
	exit(EXIT_FAILURE);
    }

    /* modify operation */
    if (uxds_acct_mod(USER, mdata, ld) != 0) {
	fprintf(stderr, "uxds_acct_mod USER MODIFY failed.\n");
	exit(EXIT_FAILURE);
    }
    /* unbind from ds - commented out due to weird bug between ldap_unbind_ext_s and openssl */
#if 0
    if (uxds_ldap_unbind(ld) != 0) {
	fprintf(stderr, "uxds_ldap_unbind failed.\n");
	exit(EXIT_FAILURE);
    }
#endif
    exit(EXIT_SUCCESS);
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
    LDAP *ld;
    int rc;
    uxds_bind_t sflag;
    uxds_authz_t auth;
    uxds_data_t mdata;
    char *bin = argv[0];
    sflag = parse_args(argc, argv, USER, ADD, 10, &auth, &mdata, bin);

    /* initialize LDAP context */
    rc = ldap_initialize(&ld, auth.uri);
    if (rc != LDAP_SUCCESS) {
	fprintf(stderr, "Could not create LDAP session handle (%d): %s\n",
		rc, ldap_err2string(rc));
	exit(EXIT_FAILURE);
    }

    /* authenticate */
    if (uxds_user_authz(sflag, auth, ld) != 0) {
	fprintf(stderr, "uxds_user_authz failed.\n");
	exit(EXIT_FAILURE);
    }

    /* add operation */
    if (uxds_acct_add(USER, mdata, ld) != 0) {
	fprintf(stderr, "uxds_acct_add USER ADD failed.\n");
	exit(EXIT_FAILURE);
    }

    /* unbind from ds when request completed */
    if (uxds_ldap_unbind(ld) != 0) {
	fprintf(stderr, "uxds_ldap_unbind failed.\n");
	exit(EXIT_FAILURE);
    }
    exit(EXIT_SUCCESS);
}