Last login time is not captured in the LDAP integration

Kiran66
Kilo Contributor

I have added the last login time attribute to the user form and mapped to the AD filed attribute in the import user table.

However, when we ran the LDAP integration, last login time is not capturing from the AD. For few users it is capturing the system generated time stamp. Could anyone suggest us how to capture the last login time stamp from the AD?

Thank you!

1 ACCEPTED SOLUTION

The problem with your script is you are literally returning the string "adt" instead of the value of the variable.

View solution in original post

15 REPLIES 15

What does the data look like in the import set table for the AD lastlogontime attribute?

Kiran66
Kilo Contributor

Hi Jim,

Sorry for the delay in response.

The value that we are getting to the import set table is "131871081929107968"

I have tried to capture by creating a string custom field and mapped it. It's getting updated.

However, problem in converting and updating the Date custom field.

Code I have written is 

var gdt = new GlideDateTime();
var mstime = (source.u_lastlogontimestamp);
gdt.setNumericValue((mstime - 116444736000000000)/10000);
gdt.getValue();
gdt.setDisplayValue(gdt.getValue());
var adt = gdt.getDisplayValue();
return "adt";

Please advise!

The problem with your script is you are literally returning the string "adt" instead of the value of the variable.

Kiran,

 Below is the script that I use to get last login time from AD to SN field.

Transform script onBefore

Script

// Updates the SN last logon field   
var n = source.u_lastlogontimestamp;  
var s = n.toString();  

if (s.charAt(0) == 1) {  
	var dtUtil = new DateTimeUtils(); 
	target.u_last_logon = dtUtil.int8ToGlideDateTime(n); 
}else if(!target.u_lastlogontimestamp.nil()) {  
	target.u_last_logon = '';  
}  

Kiran66
Kilo Contributor

Thanks Mike,

I tried the above and it didn't work for me.

However, I have also tried as per the Jim's advise and it worked for me.

Thank you all, for looking into this 🙂