I have requirement to pass user name and password from my application Login page , once user provide user name and password i need to authenticate user using Active directory.
Please note: User name here is the Windows Live Id and Password is the Password for the live id account.
When i am using below code i am getting missing_federation_metadata_urlerror code for live id account but same is working fine for internal org id.
Code publicstaticstring GetAuthenticationHeader(string tentant = "Common")
{
UserCredential uc =newUserCredential("Live Id","Password");
AuthenticationResult result =null;
var thread =newThread(() =>
{
try
{
var context =newAuthenticationContext(string.Format("https://login.windows.net/{0}","Federation End Point"));
result = context.AcquireToken(
resource:ConfigurationManager.AppSettings["WindowsManagementUri"],
clientId:ConfigurationManager.AppSettings["AsaClientId"],
userCredential: uc);
}
catch (Exception threadEx)
{
Console.WriteLine(threadEx.Message);
}
});
thread.SetApartmentState(ApartmentState.STA);
thread.Name ="AcquireThread";
thread.Start();
thread.Join();
if (result !=null)
{
return result.AccessToken;
}
thrownewInvalidOperationException("test");
}
Please Suggest.