Extend credentials python API to include set_machine_account.
[samba.git] / source4 / auth / credentials / credentials.i
index 565221c466ad736671dc1a0ec452043d294bf5c1..152d2e673ccd84c1b5ab2fabea7ed7b2c1690b6b 100644 (file)
 
 #include "includes.h"
 #include "auth/credentials/credentials.h"
+#include "param/param.h"
+#include "lib/cmdline/credentials.h"
 typedef struct cli_credentials cli_credentials;
 %}
 
-%include "carrays.i"
-%include "typemaps.i"
+%import "carrays.i"
+%import "typemaps.i"
+%import "param/param.i"
 
-%typemap(default) struct cli_credentials * {
+%typemap(default,noblock=1) struct cli_credentials * {
     $1 = NULL;
 }
 
+%constant int AUTO_USE_KERBEROS = CRED_AUTO_USE_KERBEROS;
+%constant int DONT_USE_KERBEROS = CRED_DONT_USE_KERBEROS;
+%constant int MUST_USE_KERBEROS = CRED_MUST_USE_KERBEROS;
+
 %{
 #include "librpc/gen_ndr/samr.h" /* for struct samr_Password */
 %}
 
-%typemap(out) struct samr_Password * {
-    $result = PyString_FromStringAndSize($1->hash, 16);
+%typemap(out,noblock=1) struct samr_Password * {
+    $result = PyString_FromStringAndSize((char *)$1->hash, 16);
 }
 
+%talloctype(cli_credentials);
 %rename(Credentials) cli_credentials;
 typedef struct cli_credentials {
     %extend {
-        cli_credentials() {
+        cli_credentials(void) {
             return cli_credentials_init(NULL);
         }
-        ~cli_credentials() {
-            talloc_free($self);
-        }
         /* username */
         const char *get_username(void);
         bool set_username(const char *value, 
@@ -73,25 +78,51 @@ typedef struct cli_credentials {
         bool set_realm(const char *val, 
                        enum credentials_obtained=CRED_SPECIFIED);
 
+       /* Kerberos */
+        void set_kerberos_state(enum credentials_use_kerberos use_kerberos);
+
         void parse_string(const char *text,
-                       enum credentials_obtained=CRED_SPECIFIED);
+                         enum credentials_obtained=CRED_SPECIFIED);
 
         /* bind dn */
         const char *get_bind_dn(void);
         bool set_bind_dn(const char *bind_dn);
 
+       void set_anonymous();
+
         /* workstation name */
         const char *get_workstation(void);
         bool set_workstation(const char *workstation, 
                              enum credentials_obtained obtained=CRED_SPECIFIED);
 
-        void guess(struct loadparm_context *lp_ctx = NULL);
+        NTSTATUS set_machine_account(struct loadparm_context *lp_ctx);
+
+        void guess(struct loadparm_context *lp_ctx);
         bool is_anonymous(void);
 
         const struct samr_Password *get_nt_hash(TALLOC_CTX *mem_ctx);
 
-        bool authentication_requested();
+        bool authentication_requested(void);
 
-        bool wrong_password();
+        bool wrong_password(void);
+
+        bool set_cmdline_callbacks();
     }
 } cli_credentials;
+
+%{
+struct cli_credentials *cli_credentials_from_py_object(PyObject *py_obj)
+{
+    struct cli_credentials *ret;
+
+    if (py_obj == Py_None) {
+        return cli_credentials_init_anon(NULL);
+    }
+
+    if (SWIG_ConvertPtr(py_obj, (void *)&ret, SWIGTYPE_p_cli_credentials, 0 |  0 ) < 0) {
+        return NULL; 
+    }
+    return ret;
+}
+
+%}