共用方式為


大整數屬性型別

Active Directory 網域服務結構描述屬性 (如 lastLogon) 使用 LargeInteger 語法類型。如需有關 lastLogon 屬性或 LargeInteger 語法類型的詳細資訊,請參閱 MSDN Library (網址為 https://go.microsoft.com/fwlink/?LinkID=27252 (本頁面可能為英文)) 中的<lastLogon>或<LargeInteger>。

如果以 Properties 屬性取得這種屬性類型,則會以可轉型為 IADsLargeInteger 的 COM 物件代表此資料類型。如需有關 IADsLargeInteger 類型的詳細資訊,請參閱 MSDN Library (網址為 https://go.microsoft.com/fwlink/?LinkID=27252 (本頁面可能為英文)) 中的<IADsLargeInteger>。

如果這種屬性取自 ResultPropertyValueCollection,則會以 Int64 結構代表此資料類型。

下列範例示範如何從 IADsLargeInteger 類型轉換成 DateTime 類型。

public static DateTime GetDateTimeFromLargeInteger(IADsLargeInteger largeIntValue)
{
    //
    // Convert large integer to int64 value
    //
    long int64Value = (long)((uint)largeIntValue.LowPart +
             (((long)largeIntValue.HighPart) << 32 ));  

    //
    // Return the DateTime in utc
    //
    return DateTime.FromFileTimeUtc(int64Value);
}

下列範例示範如何從 DateTime 格式轉換成 IADsLargeInteger。

public static IADsLargeInteger GetLargeIntegerFromDateTime(DateTime dateTimeValue)
{
    //
    // Convert DateTime value to utc file time
    //
    Int64 int64Value = dateTimeValue.ToFileTimeUtc();

    //
    // convert to large integer
    //
    IADsLargeInteger largeIntValue = 
         IADsLargeInteger) new LargeInteger();
    largeIntValue.HighPart = (int) (int64Value >> 32);
    largeIntValue.LowPart = (int) (int64Value & 0xFFFFFFFF);

    return largeIntValue;
}

請參閱

參考

System.DirectoryServices
DirectoryEntry
ResultPropertyValueCollection

概念

屬性型別

Send comments about this topic to Microsoft.

Copyright © 2007 by Microsoft Corporation.All rights reserved.