Try using lastLogonTimestamp in place of lastLogon in case lastLogon is null. Resolves #98.

This commit is contained in:
Alex Seigler 2020-03-18 11:09:04 -04:00 committed by Michael Grafnetter
parent de3af8afff
commit c27b62913e
1 changed files with 7 additions and 0 deletions

View File

@ -356,6 +356,13 @@
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;