Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I use a Microsoft Account to authenticate to my website

I have a website where a users identity is needed, I'd really prefer not to make them create yet another username/password combo that they have to remember

are there SDK's for allowing authentication from an Microsoft account?

like image 667
stuck Avatar asked Aug 12 '13 17:08

stuck


People also ask

How do you authenticate a Microsoft account?

Go to your personal Microsoft account sign-in page, and then instead of typing your password, select the Use the Microsoft Authenticator app instead link. Microsoft sends a notification to your phone. Approve the notification.

What does Microsoft use for authentication?

The Windows operating system implements a default set of authentication protocols, including Kerberos, NTLM, Transport Layer Security/Secure Sockets Layer (TLS/SSL), and Digest, as part of an extensible architecture.

What will a Microsoft account allow a user to do?

A Microsoft account is a free account you use to access many Microsoft devices and services, such as the web-based email service Outlook.com (also known as hotmail.com, msn.com, live.com), Office Online apps, Skype, OneDrive, Xbox Live, Bing, Windows, or the Microsoft Store.

How do I use Microsoft login?

Go to Microsoft account and select Sign in. Type the email, phone number, or Skype sign-in that you use for other services (Outlook, Office, etc.), then select Next. If you don't have a Microsoft account, you can select No account? Create one!.


3 Answers

That's rather easy as a default empty template of an ASP.NET 4.5 website shows how to have OAuth2 authentication with google/facebook/liveid/twitter.

http://www.asp.net/aspnet/overview/aspnet-45/oauth-in-the-default-aspnet-45-templates

like image 184
Wiktor Zychla Avatar answered Oct 11 '22 14:10

Wiktor Zychla


Check out the Principal Context class. You can create it using a localhost (Machine) or domain context and use the ValidateCrentials(string username, string password) method to authenticate using Windows credentials.

http://msdn.microsoft.com/en-us/library/bb154889.aspx

Here's how I've used it in my website. (Put this in a POST method of your authentication controller or something)

The code below will take a username say "bob" or "localhost\bob" or "DOMAIN\bob" etc., and get the right PrincipalContext for authenticating the user. NOTE: it's case insensitive here.

        public bool ValidateCredentials(string username, System.Security.SecureString password)
    {
        string domain = Environment.MachineName;
        if (username.Contains("\\"))
        {
            domain = username.Split('\\')[0];
            username = username.Split('\\')[1];
        }

        if (domain.Equals("localhost", StringComparison.CurrentCultureIgnoreCase))
            domain = Environment.MachineName;

        if (domain.Equals(Environment.MachineName, StringComparison.CurrentCultureIgnoreCase))
            using (PrincipalContext context = new PrincipalContext(ContextType.Machine))
            {
                return context.ValidateCredentials(username, password.ToUnsecureString());
            }
        else
            using(PrincipalContext context = new PrincipalContext(ContextType.Domain))
            {
                //return context.ValidateCredentials(domain + "\\" + username, password.ToUnsecureString());
                return context.ValidateCredentials(username, password.ToUnsecureString());
            }


    }
like image 22
C. Tewalt Avatar answered Oct 11 '22 15:10

C. Tewalt


Microsoft provides the Live Connect SDK for integration Microsoft services into your applications, including the Microsoft Accounts identity provider.

There is a specific example on Server-Side Scenarios which should cover all you need to get integrated.

like image 39
Paul Turner Avatar answered Oct 11 '22 16:10

Paul Turner