Why isn't the result of an OpenQuery refreshing? I'm trying to get some data from the Active Directory in SQL. I use the code:

SELECT * FROM OpenQuery 
( 
ADSI, 
'SELECT  objectGUID, objectSID, employeeID, lastLogon, mobile, telephoneNumber, mail,  department, givenName, sn, displayname,  sAmAccountName
FROM ''LDAP://DC=mycompany''    
where  objectClass = ''user''
and sAmAccountName = ''testuser'''  
)


My problem is that the value i receive for lastLogon isn't refreshing. It is possible that the other values aren't also refreshing, however i can't say this for sure, because in the other data there is no change, but the lastLogon value should be updated when i lock my computer and log in.

Does anyone have any idee why is this, and how can i solve this?

Thanks!
The lastLogon attribute reflects the last interactive logon, not the last network-based logon

More info found here

This is some excellent information from this site


  Another twist: Active Directory does NOT replicate the LastLogon
  attribute across domain controllers. So in order to get an accurate
  value, you need to obtain the LastLogon value for the same user from
  all your domain controllers and accept the value that is highest.