mirror of
https://github.com/samba-team/samba.git
synced 2025-03-12 20:58:37 +03:00
s3:netapi: Use public functions for username/password
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Guenther Deschner <gd@samba.org>
This commit is contained in:
parent
0aeca4e5a1
commit
fd78554d11
@ -72,6 +72,9 @@ static WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx,
|
||||
struct client_ipc_connection *p;
|
||||
NTSTATUS status;
|
||||
struct cli_credentials *creds = NULL;
|
||||
const char *username = NULL;
|
||||
const char *password = NULL;
|
||||
NET_API_STATUS rc;
|
||||
|
||||
if (!ctx || !pp || !server_name) {
|
||||
return WERR_INVALID_PARAMETER;
|
||||
@ -89,17 +92,30 @@ static WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx,
|
||||
if (!auth_info) {
|
||||
return WERR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
|
||||
rc = libnetapi_get_username(ctx, &username);
|
||||
if (rc != 0) {
|
||||
TALLOC_FREE(auth_info);
|
||||
return WERR_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
rc = libnetapi_get_password(ctx, &password);
|
||||
if (rc != 0) {
|
||||
TALLOC_FREE(auth_info);
|
||||
return WERR_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
set_cmdline_auth_info_signing_state_raw(auth_info, SMB_SIGNING_IPC_DEFAULT);
|
||||
set_cmdline_auth_info_use_kerberos(auth_info, ctx->use_kerberos);
|
||||
set_cmdline_auth_info_username(auth_info, ctx->username);
|
||||
if (ctx->password) {
|
||||
set_cmdline_auth_info_password(auth_info, ctx->password);
|
||||
set_cmdline_auth_info_username(auth_info, username);
|
||||
if (password != NULL) {
|
||||
set_cmdline_auth_info_password(auth_info, password);
|
||||
} else {
|
||||
set_cmdline_auth_info_getpass(auth_info);
|
||||
}
|
||||
|
||||
if (ctx->username && ctx->username[0] &&
|
||||
ctx->password && ctx->password[0] &&
|
||||
if (username && username[0] &&
|
||||
password && password[0] &&
|
||||
ctx->use_kerberos) {
|
||||
set_cmdline_auth_info_fallback_after_kerberos(auth_info, true);
|
||||
}
|
||||
|
@ -429,7 +429,9 @@ WERROR NetGetJoinableOUs_l(struct libnetapi_ctx *ctx,
|
||||
if (r->in.account) {
|
||||
ads->auth.user_name = SMB_STRDUP(r->in.account);
|
||||
} else {
|
||||
const char *username = cli_credentials_get_username(ctx->creds);
|
||||
const char *username = NULL;
|
||||
|
||||
libnetapi_get_username(ctx, &username);
|
||||
if (username != NULL) {
|
||||
ads->auth.user_name = SMB_STRDUP(username);
|
||||
}
|
||||
@ -439,7 +441,9 @@ WERROR NetGetJoinableOUs_l(struct libnetapi_ctx *ctx,
|
||||
if (r->in.password) {
|
||||
ads->auth.password = SMB_STRDUP(r->in.password);
|
||||
} else {
|
||||
const char *password = cli_credentials_get_password(ctx->creds);
|
||||
const char *password = NULL;
|
||||
|
||||
libnetapi_get_password(ctx, &password);
|
||||
if (password != NULL) {
|
||||
ads->auth.password = SMB_STRDUP(password);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user