Azure / azure-libraries-for-net

Azure libraries for .Net
MIT License
378 stars 193 forks source link

[BUG] NullReferenceException when adding PasswordCredential to AAD application #1149

Open eskaufel opened 3 years ago

eskaufel commented 3 years ago

Describe the bug DefinePasswordCredential for ActiveDirectoryApplications throws NullReferenceException when used to update existing AAD Application.

Exception or Stack Trace

Object reference not set to an instance of an object.

   at Microsoft.Azure.Management.Graph.RBAC.Fluent.ActiveDirectoryApplicationImpl.WithPasswordCredential[T](PasswordCredentialImpl`1 credential)
   at Microsoft.Azure.Management.Graph.RBAC.Fluent.ActiveDirectoryApplicationImpl.Microsoft.Azure.Management.Graph.RBAC.Fluent.IHasCredential<Microsoft.Azure.Management.Graph.RBAC.Fluent.ActiveDirectoryApplication.Update.IUpdate>.WithPasswordCredential(PasswordCredentialImpl`1 credential)
   at Microsoft.Azure.Management.Graph.RBAC.Fluent.PasswordCredentialImpl`1.Attach()
   at Microsoft.Azure.Management.Graph.RBAC.Fluent.PasswordCredentialImpl`1.Microsoft.Azure.Management.ResourceManager.Fluent.Core.ChildResource.Update.IInUpdate<T>.Attach()

To Reproduce Authorize then use provided code snippet

Code Snippet

Azure.ActiveDirectoryApplications.
    GetById("some object id").
    Update().
    DefinePasswordCredential("PasswordName").
        WithPasswordValue("SecretPassword").
        Attach();

Expected behavior The client secret/password to be added the to AAD application

Screenshots NA

Setup (please complete the following information):

Additional context NA

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

weidongxu-microsoft commented 3 years ago

@xccc-msft

It seems AAD changed it payload somehow. Please take a look next sprint.

jujinfu commented 2 years ago

found out a way of working this around for myself

instead of Azure.ActiveDirectoryApplications. GetById("some object id"). Update(). DefinePasswordCredential("PasswordName"). WithPasswordValue("SecretPassword"). Attach();

you need to do some other things: Azure.ActiveDirectoryApplications.Manager.Applications. GetById("some object id"). Update(). DefinePasswordCredential("PasswordName"). WithPasswordValue("SecretPassword"). Attach();