mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
remove auth type from user (#22905)
* remove auth type from user * vbump sts
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import { getErrorMessage } from '../utils';
|
||||
import { ObjectManagement } from 'mssql';
|
||||
import * as localizedConstants from './localizedConstants';
|
||||
|
||||
export function deepClone<T>(obj: T): T {
|
||||
@@ -53,81 +52,6 @@ export async function refreshNode(context: azdata.ObjectExplorerContext): Promis
|
||||
}
|
||||
}
|
||||
|
||||
export function getNodeTypeDisplayName(type: string, inTitle: boolean = false): string {
|
||||
switch (type) {
|
||||
case ObjectManagement.NodeType.ApplicationRole:
|
||||
return inTitle ? localizedConstants.ApplicationRoleTypeDisplayNameInTitle : localizedConstants.ApplicationRoleTypeDisplayName;
|
||||
case ObjectManagement.NodeType.DatabaseRole:
|
||||
return inTitle ? localizedConstants.DatabaseRoleTypeDisplayNameInTitle : localizedConstants.DatabaseRoleTypeDisplayName;
|
||||
case ObjectManagement.NodeType.ServerLevelLogin:
|
||||
return inTitle ? localizedConstants.LoginTypeDisplayNameInTitle : localizedConstants.LoginTypeDisplayName;
|
||||
case ObjectManagement.NodeType.ServerLevelServerRole:
|
||||
return inTitle ? localizedConstants.ServerRoleTypeDisplayNameInTitle : localizedConstants.ServerRoleTypeDisplayName;
|
||||
case ObjectManagement.NodeType.User:
|
||||
return inTitle ? localizedConstants.UserTypeDisplayNameInTitle : localizedConstants.UserTypeDisplayName;
|
||||
case ObjectManagement.NodeType.Table:
|
||||
return localizedConstants.TableTypeDisplayName;
|
||||
case ObjectManagement.NodeType.View:
|
||||
return localizedConstants.ViewTypeDisplayName;
|
||||
case ObjectManagement.NodeType.Column:
|
||||
return localizedConstants.ColumnTypeDisplayName;
|
||||
case ObjectManagement.NodeType.Database:
|
||||
return localizedConstants.DatabaseTypeDisplayName;
|
||||
default:
|
||||
throw new Error(`Unknown node type: ${type}`);
|
||||
}
|
||||
}
|
||||
|
||||
export function getAuthenticationTypeDisplayName(authType: ObjectManagement.AuthenticationType | undefined): string | undefined {
|
||||
if (authType === undefined) { return undefined; }
|
||||
|
||||
switch (authType) {
|
||||
case ObjectManagement.AuthenticationType.Windows:
|
||||
return localizedConstants.WindowsAuthenticationTypeDisplayText;
|
||||
case ObjectManagement.AuthenticationType.AzureActiveDirectory:
|
||||
return localizedConstants.AADAuthenticationTypeDisplayText;
|
||||
default:
|
||||
return localizedConstants.SQLAuthenticationTypeDisplayText;
|
||||
}
|
||||
}
|
||||
|
||||
export function getAuthenticationTypeByDisplayName(displayValue: string): ObjectManagement.AuthenticationType {
|
||||
switch (displayValue) {
|
||||
case localizedConstants.WindowsAuthenticationTypeDisplayText:
|
||||
return ObjectManagement.AuthenticationType.Windows;
|
||||
case localizedConstants.AADAuthenticationTypeDisplayText:
|
||||
return ObjectManagement.AuthenticationType.AzureActiveDirectory;
|
||||
default:
|
||||
return ObjectManagement.AuthenticationType.Sql;
|
||||
}
|
||||
}
|
||||
|
||||
export function getUserTypeDisplayName(userType: ObjectManagement.UserType): string {
|
||||
switch (userType) {
|
||||
case ObjectManagement.UserType.WithLogin:
|
||||
return localizedConstants.UserWithLoginText;
|
||||
case ObjectManagement.UserType.WithWindowsGroupLogin:
|
||||
return localizedConstants.UserWithWindowsGroupLoginText;
|
||||
case ObjectManagement.UserType.Contained:
|
||||
return localizedConstants.ContainedUserText;
|
||||
default:
|
||||
return localizedConstants.UserWithNoConnectAccess;
|
||||
}
|
||||
}
|
||||
|
||||
export function getUserTypeByDisplayName(userTypeDisplayName: string): ObjectManagement.UserType {
|
||||
switch (userTypeDisplayName) {
|
||||
case localizedConstants.UserWithLoginText:
|
||||
return ObjectManagement.UserType.WithLogin;
|
||||
case localizedConstants.UserWithWindowsGroupLoginText:
|
||||
return ObjectManagement.UserType.WithWindowsGroupLogin;
|
||||
case localizedConstants.ContainedUserText:
|
||||
return ObjectManagement.UserType.Contained;
|
||||
default:
|
||||
return ObjectManagement.UserType.NoConnectAccess;
|
||||
}
|
||||
}
|
||||
|
||||
// https://docs.microsoft.com/sql/relational-databases/security/password-policy
|
||||
export function isValidSQLPassword(password: string, userName: string = 'sa'): boolean {
|
||||
const containsUserName = password && userName && password.toUpperCase().includes(userName.toUpperCase());
|
||||
|
||||
Reference in New Issue
Block a user