find logged in user using javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pallavsheth
    New Member
    • Jun 2009
    • 7

    #1

    find logged in user using javascript

    Hi Team,
    Can i find the logged in user using javascript? can someone please share the code for the same?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    that depends on how you log in the user. if it's server side, you probably need to do an AJAX request. if you put the username in a cookie, you should get that without problems.

    Comment

    • pallavsheth
      New Member
      • Jun 2009
      • 7

      #3
      find logged in ser using javascript

      Hi Dormilich,

      I will explain you my problem.
      I am having one app which is uploading doc using .net's impersonation functionality and using \\<path>. the code is working fine as everything is on the same .cs file. Now when i am trying to open the saved document i am using the same impersonation functionality and logging in with same user. but i am getting error while opening the doc it is asking me username/pwd which is not happening for uploading.
      code for opening the doc is on .js file and using http://<path> to read the file.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        why do you open the file using javascript?

        you can pass login details along with the url:
        Code:
        http://login:password@domain.tld

        Comment

        • pallavsheth
          New Member
          • Jun 2009
          • 7

          #5
          find logged in user using javascript

          Hi,
          Can you please help me on how to pass the service account's username and password with the url? After that will server stop opening the prompt to enter uname and password?
          my path is like this
          http://abc.abc.abc.abc/test/<path of the file>
          how to append uname pwd with this?

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            see code above (add login:password@ before the host name/address)

            Comment

            • pallavsheth
              New Member
              • Jun 2009
              • 7

              #7
              find logged in user using javascript

              Hi,
              I am not that good in js so do i have to write the domain name also?
              e.g.
              http://<uname_xyz>:<pw d_abc>@<server_ name>/<file path>
              Where to write the domain name there?
              we have diff domains name for diff regions
              e.g em,apj,am

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                Originally posted by pallavsheth
                I am not that good in js so do i have to write the domain name also?
                yes

                Originally posted by pallavsheth
                Where to write the domain name there?
                we have diff domains name for diff regions
                you write it where you do the request.

                Comment

                • pallavsheth
                  New Member
                  • Jun 2009
                  • 7

                  #9
                  find logged in user using javascript

                  Hi,
                  Thanks for quick reply.
                  I tried to embade username, pwd with the url but it is not opening. Giving error.




                  I got invalid syntax error. Page can't be displayed.

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #10
                    hm, no idea. though it works with my own server.

                    does it work when you put that in your browser's address bar?

                    Comment

                    • pallavsheth
                      New Member
                      • Jun 2009
                      • 7

                      #11
                      Hi,
                      No it is giving me error. First i tried to test it with browser only.
                      I just added username and pwd with the url.

                      Comment

                      Working...