Platform SDK: System.DirectoryServices
Large Integer Property Type
To write values to properties that require large integers, use the System.Int64 structure. To read values from properties that use large integers, use COM Interop to access IADsLargeInteger. In ADSI, large integers use the property type ADSTYPE_LARGE_INTEGER.
Note In the Active Directory Schema, the syntax name used for large integers is called LargeInteger and is represented in the Syntax row of attribute tables with the Syntax ID: 2.5.5.16.
The following code example shows how to write large integers.
[Visual Basic .NET]
Imports System.DirectoryServices
Imports ActiveDs
...
Try
Dim ent As New DirectoryEntry("LDAP://CN=My User Name,OU=Marketing,DC=fabrikam,DC=com")
Dim myNumber As System.Int64 = 523442149523
Dim LargeInt As New ActiveDs.LargeIntegerClass
LargeInt.HighPart = CType((myNumber >> 32), Integer)
myNumber = myNumber << 32
myNumber = myNumber >> 32
LargeInt.LowPart = (Convert.ToInt32(myNumber))
ent.Properties("singleLargeInteger").Value = LargeInt
ent.CommitChanges()
Catch e As Exception
Console.WriteLine(e.ToString())
End Try[C#]
System.Int64 myNumber=523442149523; LargeInteger l= new LargeInteger(); l.HighPart = (int) (myNumber >> 32); l.LowPart = (int) (myNumber & 0xFFFFFFFF); ent.Properties["singleLargeInteger"].Value = l; ent.CommitChanges();
The following code example shows how to read large integers.
[Visual Basic .NET]
Dim largeInt As System.Int64 = 0
Dim int64Val As IADsLargeInteger = CType(usr.Properties("forceLogoff").Value, IADsLargeInteger)
largeInt = int64Val.HighPart * 0x100000000.ToUInt32() + int64Val.LowPart
Console.WriteLine(largeInt)[C#]
System.Int64 largeInt=0; IADsLargeInteger int64Val = (IADsLargeInteger) ent.Properties["forceLogoff"].Value; largeInt = int64Val.HighPart * 0x100000000 + int64Val.LowPart; Console.WriteLine(largeInt);