How do I retrieve the Windows username?

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

User avatar
Sarah
Ebase User
Posts: 63
Joined: Fri Sep 07, 2007 2:42 pm
Location: Sandy, UK
Contact:

How do I retrieve the Windows username?

#1

Postby Sarah » Mon Sep 10, 2007 11:06 am

Question
I have set up the ISAPI filter and it is all running okay. How do I retrieve the Windows username?

Answer
1. Enable authentication in the IIS Web Server. You need to set "integrated Windows authentication" at the default website level.

2. Instruct Tomcat to take the authenticated user from IIS. If you are using the jk2 connector, do this by adding the following line to the jk2.properties file: request.tomcatAuthentication=false

3. Restart IIS and Tomcat.

The userid should then be available in Ebase using the $USER system variable.
0 x

ehmd
Ebase User
Posts: 53
Joined: Thu Sep 13, 2007 9:02 am
Contact:

#2

Postby ehmd » Thu Oct 11, 2007 1:47 pm

Sarah wrote:1. Enable authentication in the IIS Web Server. You need to set "integrated Windows authentication" at the default website level.

2. Instruct Tomcat to take the authenticated user from IIS. If you are using the jk2 connector, do this by adding the following line to the jk2.properties file: request.tomcatAuthentication=false

3. Restart IIS and Tomcat.

The userid should then be available in Ebase using the $USER system variable.
For Tomcat 5.5 you also need to amend the server.xml file in Ufs\UfsServer\tomcat\conf\ to add the tomcatAuthentication parameter to the Connector port e.g. :-

<Connector port="3009"
enableLookups="false" redirectPort="3443" protocol="AJP/1.3" tomcatAuthentication="false" />
0 x

User avatar
Wai
Moderator
Moderator
Posts: 165
Joined: Wed Sep 12, 2007 9:04 am
Location: Sandy, UK
Contact:

#3

Postby Wai » Fri Apr 18, 2008 3:48 pm

If you just wanted to retrieve the Windows user name and you are not concerned with doing any authentication then it is possible to get this by writing a simple custom function.

There is a method in Java that will get the Windows user name:

System.getProperty("user.name");

You could write a custom function that returns this as a String.
0 x

Vircos
Ebase User
Posts: 97
Joined: Thu Sep 13, 2007 6:07 am
Location: The Netherlands

#4

Postby Vircos » Mon Apr 21, 2008 6:12 am

Wai wrote:If you just wanted to retrieve the Windows user name and you are not concerned with doing any authentication then it is possible to get this by writing a simple custom function.

There is a method in Java that will get the Windows user name:

System.getProperty("user.name");

You could write a custom function that returns this as a String.
I think this method will only return the username of the user who's is logged in on the server which is running Ebase. Is this correct?
0 x
What's the meaning of Justice...

User avatar
Wai
Moderator
Moderator
Posts: 165
Joined: Wed Sep 12, 2007 9:04 am
Location: Sandy, UK
Contact:

#5

Postby Wai » Tue Apr 22, 2008 2:02 pm

No, yes you are right. There will need to be some kind of authentication in place to get the Windows user id for all users.
0 x

Hovik
Moderator
Moderator
Posts: 184
Joined: Tue Sep 11, 2007 8:58 am

#6

Postby Hovik » Wed Aug 13, 2008 4:32 pm

As an alternative to writing a custom function, you can use an Ebase function called javamethod, which can call any static method in any Java class in the classpath. This function is not automatically available and needs to be added to list of functions using Ebase Designer.

a. Install Ebase function called javaMethod - read Additional Supplied Functions section of the online documentation. An export of the function is available on request.

b. The fpl is:
// userid is a form field
set userid = javaMethod('java.lang.System.getProperty', 'user.name');
0 x

Indy
Ebase User
Posts: 11
Joined: Thu Sep 13, 2007 8:20 am
Location: North Herts District Council

#7

Postby Indy » Thu Sep 11, 2008 10:55 am

Hovik wrote:As an alternative to writing a custom function, you can use an Ebase function called javamethod, which can call any static method in any Java class in the classpath. This function is not automatically available and needs to be added to list of functions using Ebase Designer.

a. Install Ebase function called javaMethod - read Additional Supplied Functions section of the online documentation. An export of the function is available on request.

b. The fpl is:
// userid is a form field
set userid = javaMethod('java.lang.System.getProperty', 'user.name');
Hi Hovik..

Any chance you can send me the above custom function? As you know we've been trying to achieve this functionality for quite some time and it looks like that we might finally be able to crack it.

Thanks
0 x
Indy

User avatar
Sarah
Ebase User
Posts: 63
Joined: Fri Sep 07, 2007 2:42 pm
Location: Sandy, UK
Contact:

#8

Postby Sarah » Mon Sep 15, 2008 11:50 am

The javamethod function can be downloaded here:

http://www.ebaseftp.com/forum/forumfiles/javamethod.zip

and imported into the Ebase Designer.
0 x

User avatar
Sarah
Ebase User
Posts: 63
Joined: Fri Sep 07, 2007 2:42 pm
Location: Sandy, UK
Contact:

#9

Postby Sarah » Tue Sep 16, 2008 10:20 am

IMPORTANT NOTES:

1. The javamethod function was introduced in Ebase version 3.4.0. Previous versions of Ebase do not include this function in the Additional Supplied Functions.

2. The xml file has been supplied to facilitate the addition of the function to Ebase 3.4.0 and above. Either import the xml into the Ebase Designer OR add the function to the Designer manually by following the instructions in the Additional Supplied Functions help documentation.
0 x

User avatar
Joost
Ebase User
Posts: 49
Joined: Fri Sep 14, 2007 6:14 pm
Location: The Netherlands

#10

Postby Joost » Wed Sep 17, 2008 8:31 am

Sarah wrote:The javamethod function can be downloaded
Or you could unzip the class from a recent ufs.jar and add it to the jar currently in use. The function specification can be exported likewise from a recent Ebase version.

For the JavaMethod the following two classes are needed:
ufs\customfunctions\JavaMethod.class
common\ReflectionUtil.class

Two other useful functions are:
ufs\customfunctions\MoveFile.class
ufs\customfunctions\RequestProperty.class
0 x

User avatar
Sarah
Ebase User
Posts: 63
Joined: Fri Sep 07, 2007 2:42 pm
Location: Sandy, UK
Contact:

#11

Postby Sarah » Thu Sep 18, 2008 11:59 am

We hadn't mentioned how to copy the class from the version 3.4.0 jar file, because when upgrading to version 3.4.0 it is important to remember to remove the 2 classes that have been added to the .../WEB-INF/classes/com/ebasetech/ufs... directory. Otherwise, future changes to the code might be missed.

If anyone does add the javamethod.class and ReflectionUtil.class to a version of Ebase prior to version 3.4.0, please ensure you remove them when you upgrade.
0 x


Who is online

Users browsing this forum: No registered users and 109 guests