Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Server Variables - AUTH_USER


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 6 - Last Post: Jan 28, 2015 3:45 AM Last Post By: Pieter van Wyk
Pieter van Wyk

Posts: 8
Registered: 8/2/08
Server Variables - AUTH_USER  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 27, 2015 6:57 AM
I have a ISAPI dll written in Intraweb 12 on Delphi XE and the following code

UserName := WebApplication.Request.GetFieldByName('AUTH_USER');

Returns the name of the person logged onto the machine accessing the Intraweb app.

Using Intraweb 14 on Delphi XE 7 this does not work any more, the field contents are blank.(I tried a few).

WebApplication.Request.RawHeaders.Values['AUTH_USER']:
WebApplication.Request.GetRawHeaderValue('AUTH_USER'):
WebApplication.Request.GetServerVariableValue('AUTH_USER'):
WebApplication.Request.GetContentFieldValue('AUTH_USER'):

We have set the Authentication Methods to ‘*Integrated Windows Authentication*' on our IIS 6 server.

I'm hoping that somebody may be able to help me out.

Regards, Pieter
Alexandre Machado

Posts: 1,754
Registered: 8/10/13
Re: Server Variables - AUTH_USER  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 27, 2015 8:19 AM   in response to: Pieter van Wyk in response to: Pieter van Wyk
Hi,

Please add all the variable names that you want to the ServerController.ServerVariables list.

The only variables that IntraWeb retrieves by default are: APP_POOL_ID, SERVER_ADDR, SERVER_NAME, SERVER_PORT, SERVER_SOFTWARE

All other variables have to be added to the list. This is because WebBroker does not let you query the server variable list and get all them at once. This way, you must tell IntraWeb which variables you want, so it can retrieve their values when processing the request.

BTW: Use the THttpRequest.GetServerVariableValue() method to retrieve the value.

From our version history:

Version 14.0.26: Default server variables are now being retrieved and can be accessed through THttpRequest object. The variables are: APP_POOL_ID, SERVER_ADDR, SERVER_NAME, SERVER_PORT, SERVER_SOFTWARE
Version 14.0.19: ServerController.ServerVariables (TStringList) public property added. When deploying as ISAPI you may add to the list all the server variables that you need to access in run time (ISAPI implementation won't allow us to list all server variables, so you have to name them in advance)

If you have any issues, please let me know.

Best regards
Pieter van Wyk

Posts: 8
Registered: 8/2/08
Re: Server Variables - AUTH_USER  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 27, 2015 8:41 AM   in response to: Alexandre Machado in response to: Alexandre Machado
Hi

Thanks for the answer but I am not sure when to add the variable name to the ServerController.ServerVariables list.

I tried the following, but got an exception 'Uninitialized reply.'

procedure TIWFormMain.IWAppFormRender(Sender: TObject);
var
Ar: THttpRequest;
begin
ServerController.IWServerController.ServerVariables.Add('AUTH_USER');
IWEdit1.Text := THttpRequest(Ar).GetServerVariableValue('AUTH_USER');
end;

Regards, Pieter

Alexandre Machado wrote:
Hi,

Please add all the variable names that you want to the ServerController.ServerVariables list.

The only variables that IntraWeb retrieves by default are: APP_POOL_ID, SERVER_ADDR, SERVER_NAME, SERVER_PORT, SERVER_SOFTWARE

All other variables have to be added to the list. This is because WebBroker does not let you query the server variable list and get all them at once. This way, you must tell IntraWeb which variables you want, so it can retrieve their values when processing the request.

BTW: Use the THttpRequest.GetServerVariableValue() method to retrieve the value.

From our version history:

Version 14.0.26: Default server variables are now being retrieved and can be accessed through THttpRequest object. The variables are: APP_POOL_ID, SERVER_ADDR, SERVER_NAME, SERVER_PORT, SERVER_SOFTWARE
Version 14.0.19: ServerController.ServerVariables (TStringList) public property added. When deploying as ISAPI you may add to the list all the server variables that you need to access in run time (ISAPI implementation won't allow us to list all server variables, so you have to name them in advance)

If you have any issues, please let me know.

Best regards
Alexandre Machado

Posts: 1,754
Registered: 8/10/13
Re: Server Variables - AUTH_USER  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 27, 2015 10:10 AM   in response to: Pieter van Wyk in response to: Pieter van Wyk
Pieter van Wyk wrote:
Hi
This code:

   ServerController.IWServerController.ServerVariables.Add('AUTH_USER');


should probably be inside the ServerController.OnConfig event handler.

Once this value does not change, you may get it only once probably:

procedure TIWForm53.IWAppFormCreate(Sender: TObject);
var
  AuthUser: string;
begin
  AuthUser :=  WebApplication.Request.GetServerVariableValue('AUTH_USER');
  // do whatever you want with AuthUser 
end;
Pieter van Wyk

Posts: 8
Registered: 8/2/08
Re: Server Variables - AUTH_USER  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 28, 2015 1:54 AM   in response to: Alexandre Machado in response to: Alexandre Machado
I'm not sure that it is going to work for us in the ServerController.OnConfig event handler, as we would want to get the 'AUTH_USER' property for every user and not just once when the application starts up.

Also, any code that I add to the ServerController.OnConfig event handler causes the dll to hang. Not sure why as there is no exception, but the browser (IE and Chrome) just sits there. waiting for the server to respond. Removing the code restores normal operation.
.

Regards, Pieter
Alexandre Machado

Posts: 1,754
Registered: 8/10/13
Re: Server Variables - AUTH_USER  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 28, 2015 3:23 AM   in response to: Pieter van Wyk in response to: Pieter van Wyk
Pieter van Wyk wrote:
I'm not sure that it is going to work for us in the ServerController.OnConfig event handler, as we would want to get the 'AUTH_USER' property for every user and not just once when the application starts up.

When you add a variable name to the ServerController.ServerVariables list, it stays there during the whole application life cycle (unless you remove it yourself), and it will be used to obtain that variable in EVERY request received by your IntraWeb server, does not matter the user or session.


Also, any code that I add to the ServerController.OnConfig event handler causes the dll to hang. Not sure why as there is no exception, but the browser (IE and Chrome) just sits there. waiting for the server to respond. Removing the code restores normal operation.

Your code is exactly like this?

procedure TIWServerController.IWServerControllerBaseConfig(Sender: TObject);
begin
  ServerVariables.Add('AUTH_USER');
end;


I've just tested in an ISAPI application and it works as expected, and the application does not hang at all.
Pieter van Wyk

Posts: 8
Registered: 8/2/08
Re: Server Variables - AUTH_USER  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 28, 2015 3:45 AM   in response to: Alexandre Machado in response to: Alexandre Machado
Alexandre Machado wrote:
Your code is exactly like this?

procedure TIWServerController.IWServerControllerBaseConfig(Sender: TObject);
begin
  ServerVariables.Add('AUTH_USER');
end;

Yes.

Based on what you said, I've done it like this and it works perfectly fine..

procedure TIWServerController.IWServerControllerBaseNewSession(
  ASession: TIWApplication);
begin
  if IWServerController.ServerVariables.IndexOf('AUTH_USER') = -1 then
    IWServerController.ServerVariables.Add('AUTH_USER');
 
  ASession.Data := TIWUserSession.Create(nil, ASession);
end;


Thank you for your help.

Regards, Pieter
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02