none
Access ProxyAddress property of user using GraphServiceClient

    Question

  • Hello, I am trying to get list of proxy addresses of an user using GraphServiceClient. I am using graph.microsoft.com 

    Here is the code I am using.
            public async Task<List<string>> GetUserListProxyAddress()
            {
                List<User> userResult = new List<User>();
                List<string> userProxyList = new List<string>();
    
                GraphClientHelper graphClientHelper = new GraphServiceClient(new AzureAuthenticationProvider());
    
                IGraphServiceUsersCollectionPage user = await graphServiceClient.Users.Request().GetAsync();
                userResult.AddRange(user);
                while (user.NextPageRequest != null)
                {
                    user = await user.NextPageRequest.GetAsync();
                    userResult.AddRange(user);           
                }
    
                foreach (var userObj in userResult)
                {
                    userProxyList.Add(userObj.ProxyAddresses.ToString());
                }
    
                return userProxyList;
            }
    But it gives me an null object reference error, Can anyone please tell me how to get prosy addresses using GraphServiceClient libraries. 


    Friday, March 24, 2017 11:26 PM

All replies

  • Greetigns,

    if you look at the user entity in the Microsoft Graph API:
    https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/user

    the proxyAddresses attribute is read only.  It cannot be changed using any of the REST methods.

    proxyAddresses String collection For example: ["SMTP: bob@contoso.com", "smtp: bob@sales.contoso.com"] The any operator is required for filter expressions on multi-valued properties. Read-only, Not nullable. Supports $filter.

    Only think you can do from code is search it.

    Regards,
    MaxV (MSFT)

    Wednesday, March 29, 2017 2:38 PM
  • Another suggestion is to post this question on https://stackoverflow.com.

    Let me take a look at the code snippet and see if I can figure out why the information is note being returned as expected.

    Regards,
    MaxV (MSFT)

    Wednesday, March 29, 2017 2:41 PM
  • Are you using the GraphClientHelper for the AAD Graph? (Old Graph API.)

    Do you get the expected result if you query graph.windows.net instead of graph.microsoft.com? The objects and attributes are not identical between the two.

    Wednesday, March 29, 2017 3:45 PM
  • My suggestion is to move to the current version of the GraphClient library and take advantage of the new features in the version 1.6 of the API.  The older versions of the library had multiple problems, not to mention issues using older versions of ADAL and the AAD Graph API itself.

    Moving to the GraphClient library, ProxyAddressses are returned as a collection of strings that are very easy to enumerate.

    If you are interested in a similar example using the GraphClient library, reply on the thread and I'll see if I can locate a simplified example, or perhaps create a developer support azure incident and request information about the samples.  Azure support is very inexpensive and in some scenarios, free.

    Regards,
    MaxV (MSFT)

    Tuesday, April 04, 2017 2:31 PM