1

We run our intranet site with PHP on an iSeries with Apache. By default, PHP hosted on this box can not automatically get the username of the logged on windows user.

With asp.net pages hosted from a windows server, we can automatically get that username.

From a PHP page, call it login.php, i want to (through whatever method), call or redirect the user to an asp.net webpage hosted on a different server. This asp.net page will pass back a value (the username).

I know the syntax for retrieving the username from .net. But, what I dont want to do, is a URL redirect back to login.php with a querystring example of ?username=bob ... because it is directly visible to the users and has many obvious flaws.

How can I go about achieving this? Maybe using Ajax? Or some sort of .net code for example Request.LastUrlVisited.ReturnValue("bob"), which doesnt show in the URL bar?

I believe the asp.net page needs to specifically be a webpage, as a asp.net webservice can not retieve the username from windows.

Thanks,


Update

Through the comments, i've come to understand that an asp.net webservice CAN in fact get the username.. it does not need to be a webpage. So this opens up a bunch of possibilities to call the webservice service from php.

9
  • What kind of .Net application is it? A Web Page or Web Service? MVC or Web Forms? Commented Mar 14, 2012 at 13:25
  • the PHP page is a web page. the asp.net page is likely also a webpage because i dont believe a webservice can retrieve the windows usernames. i'll update my post with this detail as well. Commented Mar 14, 2012 at 13:26
  • instead of trying to get username from other application why not try with php? check this post if this helps you - stackoverflow.com/questions/168610/… Commented Mar 14, 2012 at 13:28
  • that only works when PHP is hosted from various other server(s). An iSeries with Apache can not do this without installing a mod such as "Mod_auth_kerb" onto the iSeries. While this is an option, it is the very last resort. Commented Mar 14, 2012 at 13:31
  • 1
    ok why not create a asp.net webservice and do a json/webservice call to asp.net webservice and get username and you can check this - stackoverflow.com/questions/2665223/… Commented Mar 14, 2012 at 13:37

2 Answers 2

2

Ok, I'm making the presumption that you can convert your .Net site to a web service. This will look something like this:

[WebMethod]
        public string GetUserName()
        {

        }

You can then call this webservice form JQuery:

  $.ajax({
    type: "POST",
    url: "blah.asmx/GetUserName",
    data: "{}",
    dataType: "text",
    success: function(username) {
      //do stuff
    }
  });

HEre's a site with a better explanation:

http://encosia.com/using-jquery-to-consume-aspnet-json-web-services/

EDIT

I would encrypt the username too

Sign up to request clarification or add additional context in comments.

Comments

2

ok why not create a asp.net webservice and do a json/webservice call to asp.net webservice and get username and you can check this - get username from Webservice

Code:

Context.Request.ServerVariables["LOGON_USER"]

1 Comment

there's the answer to your logon user issue!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.