Fix HDFS support for CU5+ BDC instances (#10577)

* Fix HDFS node auth for non-root username

* more changes
This commit is contained in:
Charles Gagnon
2020-05-27 10:17:28 -07:00
committed by GitHub
parent e8dc0d15b7
commit f568ff82d8
17 changed files with 153 additions and 53 deletions

View File

@@ -76,6 +76,12 @@ export class SqlClusterConnection {
return authType && authType.toLowerCase() === constants.integratedAuth;
}
public updateUsername(username: string): void {
if (username) {
this._user = username;
}
}
public updatePassword(password: string): void {
if (password) {
this._password = password;

View File

@@ -117,10 +117,19 @@ export class MssqlObjectExplorerNodeProvider extends ProviderBase implements azd
// Only child returned when failure happens : When failed with 'Unauthorized' error, prompt for password.
if (children.length === 1 && this.hasExpansionError(children)) {
if (children[0].errorStatusCode === 401) {
//Prompt for password
let password: string = await this.promptPassword(localize('prmptPwd', "Please provide the password to connect to HDFS:"));
if (password && password.length > 0) {
session.sqlClusterConnection.updatePassword(password);
// First prompt for username (defaulting to existing username)
let username: string = await this.promptInput(localize('promptUsername', "Please provide the username to connect to HDFS:"), session.sqlClusterConnection.user);
// Only update the username if it's different than the original (the update functions ignore falsy values)
if (username === session.sqlClusterConnection.user) {
username = '';
}
session.sqlClusterConnection.updateUsername(username);
// And then prompt for password
const password: string = await this.promptPassword(localize('prmptPwd', "Please provide the password to connect to HDFS:"));
session.sqlClusterConnection.updatePassword(password);
if (username || password) {
await node.updateFileSource(session.sqlClusterConnection);
children = await node.getChildren(true);
}
@@ -141,6 +150,15 @@ export class MssqlObjectExplorerNodeProvider extends ProviderBase implements azd
this.expandCompleteEmitter.fire(expandResult);
}
private async promptInput(promptMsg: string, defaultValue: string): Promise<string> {
return await this.prompter.promptSingle(<IQuestion>{
type: QuestionTypes.input,
name: 'inputPrompt',
message: promptMsg,
default: defaultValue
}).then(confirmed => <string>confirmed);
}
private async promptPassword(promptMsg: string): Promise<string> {
return await this.prompter.promptSingle(<IQuestion>{
type: QuestionTypes.password,