Auto fill-in username + password when user clicks a website link

6.6k views Asked by At

I am currently building an intranet site and on this site, we have websites people would frequently use.

There are a couple of websites where people need to login though. So I was wondering if there is a way to automatically fill in the username and password box on that website when the user clicks the link for it. The login info will never change and all users have to use the same login. Something that automates this process would make things easier for the user.

So in my aspx, I would have something like this (not this exact website but a different one):

<a href="https://go.litmos.com/account/Login" target="_blank">Litmos</a><br />

I'm not sure if I need to use the code behind to do what I want or maybe some Javascript.

The type of functionality I am looking for is like the one found in KeePass. Where you enter your username and password along with a website url and when you open that website from KeePass, it fills the login info for you. I realize that that is a desktop application and I'm building an ASP.NET website. I want to know if something like this is possible and if so, how.

Just so you know, I'm using C# for the code behind for the intranet site.

1

There are 1 answers

0
David Flynn On BEST ANSWER

I figured out how to do this. Make a new HTML page and add the code below to it. When done, you can create a link wherever you wanted and make the source equal to the HTML page you just created.

<html>
    <head>
        <title>Automatic Login</title>
    </head>
    <body onload="document.forms['securelog'].submit();">
        <form action="[enter the login url here]" method="post" name="securelog">
            <input type="hidden" name="userid*" value="[enter-your-username-here]">
            <input type="hidden" name="password*" value="[enter-your-password-here]">

            <!--You can get the name of the username and password fields by looking at the source code of your website's URL. some websites might have 'username' and 'password' as the names for the username and password fields.-->

        </form>
    </body>
</html>

I'm not sure if this is the best way to do this but it works.

Alternatively, if you are worried about an odd user seeing the source code for this page, you could use php to do something similar so that your username and password only appear in your php code and since php would be executed on the server, the source code wouldn't show the username and password, I think. I haven't tried that solution because I don't have php installed on this webserver, nor do I plan to install it.