• 0

[JavaScript & HTML] One for the gurus


Question

Let's say I have a website, and access to certain directories are controlled via .htaccess files. As is expected, when a user attempts to access a page or file in said directories, he is prompted with a dialog box requesting his username and password. He enters it, and has access to all folders to which he is a member (his username is valid according to the .htaccess file).

Using only HTML & JavaScript, is it possible to retrieve the user's username? A simple test would be like this:

<script type="text/javascript">
function getUsername() {
/* work your magic here */
}

var userName = getUsername();
alert('you are '+userName);
</script>

If this is possible, please help me out. Google searches and perusals through JavaScript references haven't turned up anything

Link to comment
https://www.neowin.net/forum/topic/393148-javascript-html-one-for-the-gurus/
Share on other sites

4 answers to this question

Recommended Posts

  • 0

I havent done any research, but my hunch tells me its NOT possible. Here's why:

1.) Logging in with .htaccess is a server side authentication method.

2.) HTML & Javascript are both executed on the client side.

3.) I have never every seen this done in the feild.

  • 0

here is a link on how to read a file on a server with javascript

http://www.rgagnon.com/jsdetails/js-0034.html

it may not be exactly what you want, but you may be able to modify it to your needs

as nickg78 said, it would be much easier with PHP :)

  • 0

oh, i know it'd be easy with any type of server-side language. the problem is i don't have the authority to put PHP or ASP access on the servers, and I can't be certain that those who do will allow it, so for right now I'm seeing if there are any possible client-side solutions.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Microsoft shares Defender update for new Windows 11/10 ISO installs by Sayan Sen Aside from new Windows setup and recovery updates, Microsoft has also published a new Defender update for Windows 11/10/Server installation images this week. This update package is necessary as a Windows installation image may contain old, outdated anti-malware definitions and software binaries. Aside from better security, these updates can also provide improved performance benefits in some cases. When a new Windows installation is set up, there may be a temporary security risk due to outdated Microsoft Defender protection in the OS installation images. This happens because the antimalware software included in these images might not be up to date. Thus Microsoft says that these updated definitions essentially help close this protection gap. Microsoft delivered the latest security definitions for Windows images via security intelligence update version 1.431.54.0. The Defender package version is also the same. It applies to Windows 11, Windows 10 (Enterprise, Pro, and Home editions), Windows Server 2022, Windows Server 2019, and Windows Server 2016. Microsoft writes: From Microsoft's security bulletin, we learn that the security intelligence update version 1.431.452.0 was released this past week adds threat detections for various backdoor and phishing exploits, trojans, and more. For those wondering, the latest intelligence update is version 1.431.155.0 at the time of writing.
    • Probably.   You'll probably want to see what channels you'd pick up by entering your zip code here... https://www.channelmaster.com/pages/free-tv-channels   With respect to the antenna and box you selected... no idea.  They are both non-brand names and cheap.  So...sure.  I have no idea how that box records...but it's listed as a feature. Also...I have no recommendations.  I haven't recorded from a cable box (ClearQAM) in over 10 years (maybe 20?).  This was Windows Media Center/MythTV days.  My Hauppauge is just collecting dust somewhere in my expansion slot bin.
    • Yea, I tried to do that with my janky WINDOWS MEDIA CENTER Frankenstein, and it failed miserably.
    • Right next to you, buddy, we can go together 😄, God knows you need it more than me!
    • Six hours later, the price on Amazon was $399. Took a while.
  • Recent Achievements

    • First Post
      smileyhead earned a badge
      First Post
    • One Month Later
      K V earned a badge
      One Month Later
    • Week One Done
      K V earned a badge
      Week One Done
    • Dedicated
      CarlosABC earned a badge
      Dedicated
    • One Month Later
      solidox earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      640
    2. 2
      ATLien_0
      240
    3. 3
      Xenon
      172
    4. 4
      neufuse
      155
    5. 5
      +FloatingFatMan
      122
  • Tell a friend

    Love Neowin? Tell a friend!