none
How to get NetworkCredential object from [item].Server.Credentials object RRS feed

  • Question

  • I need to check if, in the current call, the credentials for a cached in memory item (say a folder object) are still correct. To do so, I would like to compare them to the item's Service.Credentials against the user's current exchange credentials that I also have in memory. 

    In the debugger, I can see that Credentials derives from NetworkCredential. However, I can't cast it or coerce its type such that I have access to at least the username (which is all I need).  An implicit conversion exists the other way round. 

    Any way to do this? All I have is the item's Service object. 

    Thanks


    Tuesday, September 4, 2012 11:38 PM

All replies

  • WebCredentials wraps ICredentials which you can then get the NetworkCredentials from (if one exists) eg

                WebCredentials cred = (WebCredentials)service.Credentials;
                Console.Write(((NetworkCredential)cred.Credentials).UserName);
    Cheers
    Glen
    Wednesday, September 5, 2012 5:11 AM