WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Novell Netware
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get Last Login time from Netware

 Keywords:  Last Login time Netware

Question:

Can winbatch get the last login time? I know how to do this using nlist but am wondering about doing it with winbatch. thanks

Answer:

Yes, this can be retrieved. There are two NDS attributes of interest here. The first one is "Login Time" and the second one is "Last Login Time". These are both of type SYN_TIME. They are returned as a positive integer value representing the number of seconds elapsed since "1970:01:01:00:00:00". The time values are UTC time values, so any translation of them into YYYY:MM:DD:hh:mm:ss format needs to take into account your local time zone and current daylight savings time setting. For example, the USA's Eastern Time time has an offset from UTC of -5 hours when in standard time [e.g. our "fallt/winter"], but it is only -4 hours after we "spring ahead" 1 hour when we switch over to daylight time [e.g. out "spring/summer"].

Also, please note that the value stored in the attribute "Login Time" is the value that is displayed as "Last Login Time" in NWADMIN. This value gets copied to the attribute "Last Login Time" each time you login to NDS, so your two most recent login date/time stamps are available via WinBatch [but only the most recent is available via NWADMIN].

Here is a sample script showing how to get these values using both the n4*() and nw*() functions.

AddExtender('wwn4x32i.dll')
n4SetContext('[Root]','')
username=askline("Username", "Please enter username [DN value]","")

LoginTime = n4ObjGetVal('',username,'Login Time',0,0)
LastLoginTime = n4ObjGetVal('',username,'Last Login Time',0,0)

LoginTimeX =
TimeAdd('1970:01:01:00:00:00',StrCat('0000:00:00:00:00:',LoginTime))
LastLoginTimeX =
TimeAdd('1970:01:01:00:00:00',StrCat('0000:00:00:00:00:',LastLoginTime))

TempMsg = StrCat('Username = "',username,'"',@CRLF)
TempMsg = StrCat(TempMsg,@CRLF,'Login Time (seconds since zero time)
UTC: ',LoginTime)
TempMsg = StrCat(TempMsg,@CRLF,'Login Time (YYYY:MM:DD:hh:mm:ss)
UTC: "',LoginTimeX,'"')
TempMsg = StrCat(TempMsg,@CRLF,'Last Login Time (seconds since zero
time) UTC: ',LastLoginTime)
TempMsg = StrCat(TempMsg,@CRLF,'Last Login Time
(YYYY:MM:DD:hh:mm:ss) UTC: "',LastLoginTimeX,'"')


Message('Result using n4*() functions:',TempMsg)

AddExtender('wwnwu34i.dll')

nwSetContext(0,'[Root]','')

LoginTime = nwGetObjValue(username,'Login Time',0,0,1)
LastLoginTime = nwGetObjValue(username,'Last Login Time',0,0,1)

LoginTimeX =
TimeAdd('1970:01:01:00:00:00',StrCat('0000:00:00:00:00:',LoginTime))
LastLoginTimeX =
TimeAdd('1970:01:01:00:00:00',StrCat('0000:00:00:00:00:',LastLoginTime))

TempMsg = StrCat('Username = "',username,'"',@CRLF)
TempMsg = StrCat(TempMsg,@CRLF,'Login Time (seconds since zero time)
UTC: ',LoginTime)
TempMsg = StrCat(TempMsg,@CRLF,'Login Time (YYYY:MM:DD:hh:mm:ss)
UTC: "',LoginTimeX,'"')
TempMsg = StrCat(TempMsg,@CRLF,'Last Login Time (seconds since zero
time) UTC: ',LastLoginTime)
TempMsg = StrCat(TempMsg,@CRLF,'Last Login Time
(YYYY:MM:DD:hh:mm:ss) UTC: "',LastLoginTimeX,'"')
Message('Result using nw*() functions:',TempMsg)
exit

Article ID:   W14892
File Created: 2001:11:08:12:40:50
Last Updated: 2001:11:08:12:40:50