libnetapi: add libnetapi_set_use_kerberos
authorGünther Deschner <gd@samba.org>
Sun, 13 Apr 2008 17:22:24 +0000 (19:22 +0200)
committerGünther Deschner <gd@samba.org>
Sun, 13 Apr 2008 17:25:59 +0000 (19:25 +0200)
Don't unconditionally set the kerberos flag for authentication.

Guenther

source/lib/netapi/cm.c
source/lib/netapi/examples/common.c
source/lib/netapi/netapi.c
source/lib/netapi/netapi.h

index 96087247d2798b720dba96d4c21adfee8f5d09a1..071ebfd4bcbda8739e9e0eab1dd36e1f418d603e 100644 (file)
@@ -36,7 +36,10 @@ WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx,
        }
 
        cli_cm_set_signing_state(Undefined);
-       cli_cm_set_use_kerberos();
+
+       if (ctx->use_kerberos) {
+               cli_cm_set_use_kerberos();
+       }
 
        if (ctx->password) {
                cli_cm_set_password(ctx->password);
@@ -46,7 +49,8 @@ WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx,
        }
 
        if (ctx->username && ctx->username[0] &&
-           ctx->password && ctx->password[0]) {
+           ctx->password && ctx->password[0] &&
+           ctx->use_kerberos) {
                cli_cm_set_fallback_after_kerberos();
        }
 
index 2c3e4d711d3546764bd0a5b640ce5dbe03f9aaf3..74e28616bfe7d018eb52ce81461882606c618097 100644 (file)
@@ -48,6 +48,9 @@ void popt_common_callback(poptContext con,
                case 'p':
                        libnetapi_set_password(ctx, arg);
                        break;
+               case 'k':
+                       libnetapi_set_use_kerberos(ctx);
+                       break;
        }
 }
 
@@ -56,6 +59,7 @@ struct poptOption popt_common_netapi_examples[] = {
        { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Username used for connection", "USERNAME" },
        { "password", 'p', POPT_ARG_STRING, NULL, 'p', "Password used for connection", "PASSWORD" },
        { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Debuglevel", "DEBUGLEVEL" },
+       { "kerberos", 'k', POPT_ARG_NONE, NULL, 'k', "Use Kerberos", NULL },
        POPT_TABLEEND
 };
 
index f15e5bf067cb22dd0ba5d0c11c8ea038f6588fe3..9e309634b46716ab26a5d96cafd88ef290813721 100644 (file)
@@ -211,6 +211,15 @@ NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx,
 /****************************************************************
 ****************************************************************/
 
+NET_API_STATUS libnetapi_set_use_kerberos(struct libnetapi_ctx *ctx)
+{
+       ctx->use_kerberos = true;
+       return NET_API_STATUS_SUCCESS;
+}
+
+/****************************************************************
+****************************************************************/
+
 const char *libnetapi_errstr(NET_API_STATUS status)
 {
        if (status & 0xc0000000) {
index 97fed2e1d3298b76fb85d02593c44eb1c3d7dbeb..0d21067a20eb5e571c0a05a3efb956b54648b19b 100644 (file)
@@ -89,6 +89,7 @@ struct libnetapi_ctx {
        char *workgroup;
        char *password;
        char *krb5_cc_env;
+       int use_kerberos;
 };
 
 /****************************************************************
@@ -133,6 +134,11 @@ NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx,
 /****************************************************************
 ****************************************************************/
 
+NET_API_STATUS libnetapi_set_use_kerberos(struct libnetapi_ctx *ctx);
+
+/****************************************************************
+****************************************************************/
+
 const char *libnetapi_errstr(NET_API_STATUS status);
 
 /****************************************************************