We have an internal app that is used at different locations. I would like to know the location of the user. Is there a way to retrieve the IP address of the user within the Valence back-end application?
Announcement
Collapse
No announcement yet.
User's IP/Location
Collapse
X
-
The IP address is stamped on the session record for the user (file VVSESSDATA), so you should be able to get at it via the session ID. Something like this in your RPG should work:
Code:// pull in session ID, which is passed automatically on each Ajax call ("sid" is a 64 char alpha field) sid = vvIn_char('sid'); // retreive IP address from session record ("ipAddress" is a 20 char alpha field) exec sql select vvClientIp into :ipAddress from vvsessdata where vvsessid=:sid;
Last edited by robert.swanson; 08-22-2016, 04:46 PM.
-
Alternative method: use vvUtility_getSessVar. Documentation is at http://service.cnxcorp.com/valence-5...lkit.vvUtility. Look at the example RPG code in the doc for getSessVar. You want to set up something similar. The value in the session structure you're looking for is vvClientIP.
Comment
-
Originally posted by richard.milone View PostAlternative method: use vvUtility_getSessVar. Documentation is at http://service.cnxcorp.com/valence-5...lkit.vvUtility. Look at the example RPG code in the doc for getSessVar. You want to set up something similar. The value in the session structure you're looking for is vvClientIP.
Comment
-
That technique should still work fine. Here's an explicit example (RPG):Code:/copy qcpylesrc,vvHspec d sessVar e ds extname(VVSESSDATA) qualified /include qcpylesrc,vvDspec sessVar=vvUtility_getSessVar(VVSESSVAR); vvOut_toJsonPair('success:true,'+ 'ipAddress:'+%trim(sessVar.vvClientIP)+','+ 'ibmIuser:'+%trim(sessVar.vvibmiuser)); *inlr=*on;
Comment
-
Code:/include qcpylesrc,vvHspec d sessDS e ds extname(vvSessData) qualified /include qcpylesrc,vvDspec SessDS = vvUtility_getSessVar(VVSESSVAR); userIP = sessDS.vvClientIP;
SESSDS
VVSESSID = SZEST51FHG4NPVRYDT1LEKYBMDHQWCISEVUP8KZLN15JXR6LV6 7ZHXL1TD0IDLU8
VVTS_LOGIN = 2020-05-18-10.56.38.750000
VVTS_ACT = 2020-05-18-10.56.43.639000
VVUSRID = 000001020.
VVENVID = 000001001.
VVMETHOD = IBMI
VVSPLAUTH =
VVMODE = desktop
VVTOKEN = t8hCOD6y8H5Y0e4iOjS8QijzaCuYMQLp
VVLIBLIST = VALENCE52P VVAPPS50 ASTHHOBJ ASTDTA WQ_TBF
VVIBMIUSER =
VVCLIENTIP =
VVNEXTPOLL =
VVLNGID =
VVLOCK =
VVLOGINID =Last edited by gwilburn; 05-18-2020, 10:08 AM.
Comment
-
Deprecated, but it still works.
Have you tried recompiling your program? VVSESSDATA.VVLIBLIST was expanded to support more libraries in 5.2.20190424.0 (capacity increased from 46 to 250). The fact that you're seeing blanks after VVLIBLIST suggests it's still using the old file structure. Recompiling the program should fix that.
Comment
-
I've recompiled the program many times... but I just checked my compile listing.. it's pulling VVSESSDATA from library VALENCE51P. UGH!
I have RDi adding my libraries at startup...
This works now that I have compiled using the correct library... Thanks.
Should i worry about the depreciated value?
BTW - there's an SQL statement to get some of this information
Comment
-
Ah, the old library list problem. Glad you got it sorted out.
This approach is only deprecated because of that fact that file structure changes to VVSESSDATA force you to recompile your program. We'll keep supporting it, but using SQL or other procedures to get at the value is a little cleaner.
Comment
Comment