NTSTATUS status;
ADS_STATUS ads_status;
ADS_STRUCT *ads = NULL;
+ struct cli_credentials *creds = NULL;
struct netr_DsRGetDCNameInfo *info = NULL;
const char *dc = NULL;
uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED |
goto out;
}
- ADS_TALLOC_CONST_FREE(ads->auth.user_name);
- if (r->in.account) {
- ads->auth.user_name = talloc_strdup(ads, r->in.account);
- if (ads->auth.user_name == NULL) {
- ret = WERR_NOT_ENOUGH_MEMORY;
- goto out;
- }
- } else {
- const char *username = NULL;
-
- libnetapi_get_username(ctx, &username);
- if (username != NULL) {
- ads->auth.user_name = talloc_strdup(ads, username);
- if (ads->auth.user_name == NULL) {
- ret = WERR_NOT_ENOUGH_MEMORY;
- goto out;
- }
- }
- }
-
- ADS_TALLOC_CONST_FREE(ads->auth.password);
- if (r->in.password) {
- ads->auth.password = talloc_strdup(ads, r->in.password);
- if (ads->auth.password == NULL) {
- ret = WERR_NOT_ENOUGH_MEMORY;
+ if (r->in.account != NULL) {
+ status = ads_simple_creds(ads,
+ r->in.domain,
+ r->in.account,
+ r->in.password,
+ &creds);
+ if (!NT_STATUS_IS_OK(status)) {
+ ret = WERR_NERR_DEFAULTJOINREQUIRED;
goto out;
}
} else {
- const char *password = NULL;
-
- libnetapi_get_password(ctx, &password);
- if (password != NULL) {
- ads->auth.password = talloc_strdup(ads, password);
- if (ads->auth.password == NULL) {
- ret = WERR_NOT_ENOUGH_MEMORY;
- goto out;
- }
- }
+ libnetapi_get_creds(ctx, &creds);
}
- ads_status = ads_connect_user_creds(ads);
+ ads_status = ads_connect_creds(ads, creds);
if (!ADS_ERR_OK(ads_status)) {
ret = WERR_NERR_DEFAULTJOINREQUIRED;
goto out;