Skip to content

Commit

Permalink
Try using lastLogonTimestamp in place of lastLogon in case lastLogon …
Browse files Browse the repository at this point in the history
…is null. Resolves #98.
  • Loading branch information
aseigler authored and MichaelGrafnetter committed Mar 18, 2020
1 parent de3af8a commit c27b629
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Src/DSInternals.Common/Data/Principals/DSAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,13 @@ protected void LoadAccountInfo(DirectoryObject dsObject, string netBIOSDomainNam
dsObject.ReadAttribute(CommonDirectoryAttributes.LastLogon, out DateTime? lastLogon);
this.LastLogon = lastLogon;

// lastLogon is not replicated, lastLogonTimestamp is but it's not as accurate, so if we can't find lastLogon, try using lastLogonTimestamp instead
if (null == lastLogon)
{
dsObject.ReadAttribute(CommonDirectoryAttributes.LastLogonTimestamp, out DateTime? lastLogonTimestamp);
this.LastLogon = lastLogonTimestamp;
}

// UPN:
dsObject.ReadAttribute(CommonDirectoryAttributes.UserPrincipalName, out string upn);
this.UserPrincipalName = upn;
Expand Down

0 comments on commit c27b629

Please sign in to comment.