Converting lastlogontimestamp to DateTime
<p>I am trying to convert a lastlogontimestamp to datetime but I have noticed for large values, I get the error Exception message: Index was out of range. Must be non-negative and less than the size of the collection.</p>

<p>Is there a better way to do the below?</p>

<pre><code>var de = new DirectoryEntry("LDAP://GLOBAL.ABC.COM");
var ds = new DirectorySearcher(de);
ds.Filter = string.Format("(&amp;(objectCategory=user)(objectClass=user)({0}={1}))", 
  "samAccountName", username);
ds.PropertiesToLoad.AddRange(new string[] { "samAccountName", "lastLogon" });
SearchResult sr = ds.FindOne();
long lastLogon = (long)sr.Properties["lastLogon"][0];
// lastLogon is 131111471723190497 
var dtLastLogon = DateTime.FromFileTime(lastLogon);
return dtLastLogon.ToString();
</code></pre>