Login.ChangePassword() leaves MustChangePassword and IsLocked stale - the property bag is never updated or invalidated
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 72/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Domínio
- backend-api-design, databases
Direção de pesquisa
Comece em src/Microsoft/SqlServer/Management/Smo/LoginBase.cs, lendo as sobrecargas de ChangePassword e ExecuteLoginPasswordOptions e, em seguida, compare o comportamento delas com SetMustChangePassword. Após uma execução bem-sucedida sem registro, invalide as propriedades afetadas armazenadas em cache para que as leituras no mesmo objeto reflitam o resultado de ALTER LOGIN para MustChangePassword, IsLocked, IsPasswordExpired, IsMustChange, PasswordLastSetTime e PasswordHash.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
After a successful Login.ChangePassword(newPassword, unlock: true, mustChange: true), reading login.MustChangePassword on the same object still returns the old value (typically False) until Refresh() is called. The same applies to the other properties the ALTER changes: IsLocked after an unlock, IsPasswordExpired, PasswordLastSetTime, IsMustChange.
This is the same object-cache pattern as #40 (Database.SetOwner() not updating .Owner): a method executes DDL immediately but neither updates nor invalidates the cached properties it just changed on the server.
Repro
$login = $server.Logins["testlogin"] # SQL login, MustChangePassword currently False
$login.ChangePassword("N3wP@ssw0rd!", $true, $true)
$login.MustChangePassword # False - stale; the server says otherwise:
# SELECT LOGINPROPERTY('testlogin', 'IsMustChange') --> 1
$login.Refresh()
$login.MustChangePassword # True
dbatools carries the workaround with the comment "We need to refresh login after ChangePassword. Otherwise, MustChangePassword will appear as False" (New-DbaLogin.ps1#L610-L611), and its Set-DbaLogin re-reads the login after unlocking for the same reason.
Mechanism
All ChangePassword overloads (LoginBase.cs#L142-L282) end in ExecuteLoginPasswordOptions (LoginBase.cs#L533-L555), which builds ALTER LOGIN ... WITH PASSWORD=... [UNLOCK] [MUST_CHANGE] and runs ExecutionManager.ExecuteNonQuery — and returns. Nothing touches the property bag.
A helper that does update the bag exists — SetMustChangePassword (LoginBase.cs#L334-L347) — but it early-returns unless the object is in design mode, and is only called from Create().
Suggested fix
After a successful non-recording execution, invalidate the affected cached properties so the next read fetches current values from the server — the approach proposed for #40 in PR #231. For ChangePassword that covers at least MustChangePassword, IsLocked, IsPasswordExpired, IsMustChange, PasswordLastSetTime, PasswordHash.
Happy to submit a PR along those lines if that helps.
This was created by Claude and reviewed by Andreas Jordan.
- Linguagem predominante
- C#
- Estrelas
- 143
- Forks
- 29
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de microsoft/sqlmanagementobjects
-
Path parsing functions are incorrect when running on LinuxTalvez já em andamento @shueybubbles assumiu há 3 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 74/100
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 78/100
-
SmoMetadataProvider throws bare NullReferenceException when the current database cannot be resolved (Azure/Fabric endpoint)Talvez já em andamento @jtorres assumiu há 58 dias. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 68/100
Todas as issues de microsoft/sqlmanagementobjects
Issues semelhantes
-
[Bug]: Missing extensions in Agent Card capabilities in v0.3 compat modeTalvez já em andamento @hwanders assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
a2aproject/a2a-dotnet#514 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
agentic-workflows untriaged
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
VS Code
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
AlamoEngine-Tools/pg-starwarsgame-lsp#207 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
elsa-workflows/elsa-core#8593 ·
Mantenedores costumam responder em até 1 dia
-
GpioController.QueryComponentInformation() throws NotSupportedException with RaspberryPi3DriverAbertauntriaged
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100