Trying to create User of External UserType against a SqlManagedInstance results in error
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Iniziare con le righe citate di UserBase.cs relative alla convalida di UserType, quindi esaminare la logica del nome del motore in SqlSmoObject.cs e LocalizableResources.strings. Riprodurre la creazione dell'utente External su SQL Managed Instance e verificare che la convalida accetti la versione e che l'errore risultante identifichi correttamente Azure SQL Managed Instance.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hi @shueybubbles, greetings from the dbatools team 😄
I'm trying to add a SqlUser of type [Microsoft.SqlServer.Management.Smo.UserType]::External on a newly created SQL MI.
DatabaseEngineEdition: SqlManagedInstance
ServerVersion.Major: 16
SMO Version: 16
File version: 16.200.46367.54
I'm getting the following exception:
Exception : System.Management.Automation.MethodInvocationException: Exception calling "Create" with "0" argument(s): "Create failed for
User 'claudio@********.onmicrosoft.com'. "
---> Microsoft.SqlServer.Management.Smo.FailedOperationException: Create failed for User
'claudio@********.onmicrosoft.com'.
---> Microsoft.SqlServer.Management.Smo.UnsupportedVersionException: 'User'.'UserType': 'External' is not a valid option for SQL Server 2017.
Code to reproduce:
$smoUser = New-Object Microsoft.SqlServer.Management.Smo.User
$smoUser.Parent = $dbSMO
$smoUser.Name = "claudio@********.onmicrosoft.com"
$smoUser.Login = "claudio@********.onmicrosoft.com"
$smoUser.UserType = [Microsoft.SqlServer.Management.Smo.UserType]::External
$smoUser.DefaultSchema = "dbo"
$smoUser.Create()
Note: with T-SQL it works.
From my analysis the problem is here (assuming the comment): https://github.com/microsoft/sqlmanagementobjects/blob/98093604e9ede97aa2a9b066279f0bd9d9557c4f/src/Microsoft/SqlServer/Management/Smo/UserBase.cs#L362-L364
It should be 12 <= this.ServerVersion.Major instead of >
Error message
Also, the error message says SQL Server 2017 when it should say SQL Server Managed Instance
It seems it's entering here:
https://github.com/microsoft/sqlmanagementobjects/blob/04249a2dc85ad1aa0d492b8a2cecf65583ded177/src/Microsoft/SqlServer/Management/Smo/SqlSmoObject.cs#L6919
I would suggest adding a new validation similar with
https://github.com/microsoft/sqlmanagementobjects/blob/04249a2dc85ad1aa0d492b8a2cecf65583ded177/src/Microsoft/SqlServer/Management/Smo/SqlSmoObject.cs#L6898-L6901
But like:
if (sp.TargetDatabaseEngineType == DatabaseEngineType.SqlAzureDatabase)
{
return LocalizableResources.EngineCloud;
}
else if (sp.TargetDatabaseEngineType == DatabaseEngineType.Standalone && sp.DatabaseEngineEdition == DatabaseEngineEdition.SqlManagedInstance)
{
return LocalizableResources.EngineCloudMI;
}
And add here:
https://github.com/microsoft/sqlmanagementobjects/blob/73cd2cb929409cb9ddc2c7b416c5d7c6ef621d5f/src/Microsoft/SqlServer/Management/Smo/LocalizableResources.strings#L26
A new entry
EngineCloudMI = Microsoft Azure SQL Managed Instance
PS: I'm more than happy to submit a PR with these changes if it's ok for you.
Thanks!
- Lingua principale
- C#
- Stelle
- 143
- Fork
- 28
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/sqlmanagementobjects
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 74/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 78/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
Tutte le issue di microsoft/sqlmanagementobjects
Issue simili
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
sillsdev/languageforge-lexbox#2665 ·
-
bug documentation frontend
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
azurenoops/spin_agent#975 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
SubtitleEdit/subtitleedit#15108 · 1 commento ·