summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/libsmbclient.h27
-rw-r--r--source3/include/proto.h1
-rw-r--r--source3/lib/util.c5
-rw-r--r--source3/libsmb/libsmb_context.c20
4 files changed, 53 insertions, 0 deletions
diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h
index 74d0d5c9dd..2828e9e780 100644
--- a/source3/include/libsmbclient.h
+++ b/source3/include/libsmbclient.h
@@ -2561,6 +2561,33 @@ smbc_version(void);
}
#endif
+/**@ingroup misc
+ * Set the users credentials globally so they can be used for DFS
+ * referrals. Probably best to use this function in the smbc_get_auth_data_fn
+ * callback.
+ *
+ * @param workgroup Workgroup of the user.
+ *
+ * @param user Username of user.
+ *
+ * @param password Password of user.
+ *
+ * @param use_kerberos Whether to use Kerberos
+ *
+ * @param signing_state One of these strings (all equivalents on same line):
+ * "off", "no", "false"
+ * "on", "yes", "true", "auto"
+ * "force", "required", "forced"
+ */
+
+void
+smbc_set_credentials(char *workgroup,
+ char *user,
+ char *password,
+ bool use_kerberos,
+ char *signing_state);
+
+
/**
* @ingroup structure
* Structure that contains a client context information
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 2a954f4efe..665a86d2c8 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1271,6 +1271,7 @@ const char *get_cmdline_auth_info_password(void);
void set_cmdline_auth_info_password(const char *password);
bool set_cmdline_auth_info_signing_state(const char *arg);
int get_cmdline_auth_info_signing_state(void);
+void set_cmdline_auth_info_use_kerberos(bool b);
bool get_cmdline_auth_info_use_kerberos(void);
void set_cmdline_auth_info_use_krb5_ticket(void);
void set_cmdline_auth_info_smb_encrypt(void);
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 68524a21ce..8d744a5ae3 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -353,6 +353,11 @@ int get_cmdline_auth_info_signing_state(void)
return cmdline_auth_info.signing_state;
}
+void set_cmdline_auth_info_use_kerberos(bool b)
+{
+ cmdline_auth_info.use_kerberos = b;
+}
+
bool get_cmdline_auth_info_use_kerberos(void)
{
return cmdline_auth_info.use_kerberos;
diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c
index dd78bcee35..51948d1648 100644
--- a/source3/libsmb/libsmb_context.c
+++ b/source3/libsmb/libsmb_context.c
@@ -610,3 +610,23 @@ smbc_version(void)
}
+/*
+ * Set the credentials so DFS will work when following referrals.
+ */
+void
+smbc_set_credentials(char *workgroup,
+ char *user,
+ char *password,
+ bool use_kerberos,
+ char *signing_state)
+{
+
+ set_cmdline_auth_info_username(user);
+ set_cmdline_auth_info_password(password);
+ set_cmdline_auth_info_use_kerberos(use_kerberos);
+ if (! set_cmdline_auth_info_signing_state(signing_state)) {
+ DEBUG(0, ("Invalid signing state: %s", signing_state));
+ }
+ set_global_myworkgroup(workgroup);
+ cli_cm_set_credentials();
+}