how to gives last logon attribute for user active directory

320 Views Asked by At

I wrote a program which gives all user attributes from active directory using novell library but unfortunately I don't get value of lastlogon attribute although this attribute contains a value.

1

There are 1 best solutions below

0
Gabriel Luci On BEST ANSWER

The lastLogon attribute is not replicated. That means it will only be accurate on the domain controller that the user last authenticated against. Any other DC will have either an old value, or no value.

You have two options:

  1. Query each DC and use the most recent value, or
  2. Use the lastLogonTimestamp attribute, which was created for just this reason. It won't give you the exact time of the last logon, but it is guaranteed to be accurate within 2 weeks.

Also make sure you are reading from the domain (LDAP://) and not the Global Catalog (GC://). Neither attribute will be available from a GC.