给你段VB代码,自己转吧。
Dim pwdLastSet As Int64
Dim pwdLastSetDate As DateTime
Dim pwdLastSetVal As ObjectpwdLastSetVal = user.Properties("pwdLastSet").Value
pwdLastSet = GetInt64FromLargeInteger(pwdLastSetVal)
pwdLastSetDate = DateTime.FromFileTime(pwdLastSet)
.....Public Shared Function GetInt64FromLargeInteger(ByVal largeInteger
As Object) As Long
Dim lowPart As Integer
Dim lBytes() As Byte
Dim highPart As Integer
Dim hBytes() As Byte
Dim valBytes(7) As Byte Dim longVal As Long
Dim largeIntType As Type largeIntType = largeInteger.GetType() Try
highPart = CType(largeIntType.InvokeMember("HighPart",
BindingFlags.GetProperty Or BindingFlags.Public, Nothing, largeInteger,
Nothing), Integer)
lowPart = CType(largeIntType.InvokeMember("LowPart",
BindingFlags.GetProperty Or BindingFlags.Public, Nothing, largeInteger,
Nothing), Integer) lBytes = BitConverter.GetBytes(lowPart)
hBytes = BitConverter.GetBytes(highPart) lBytes.CopyTo(valBytes, 0)
hBytes.CopyTo(valBytes, 4) longVal = BitConverter.ToInt64(valBytes, 0) Return longVal Catch e As MissingMethodException
Throw New ArgumentException("Invalid COM object passed as
parameter. Object must be IADsLargeInteger.", e)
End Try
End Function
注意要引入System.Reflection(using)
其中user是你的DirectoryEntry对象
Dim pwdLastSet As Int64
Dim pwdLastSetDate As DateTime
Dim pwdLastSetVal As ObjectpwdLastSetVal = user.Properties("pwdLastSet").Value
pwdLastSet = GetInt64FromLargeInteger(pwdLastSetVal)
pwdLastSetDate = DateTime.FromFileTime(pwdLastSet)
.....Public Shared Function GetInt64FromLargeInteger(ByVal largeInteger
As Object) As Long
Dim lowPart As Integer
Dim lBytes() As Byte
Dim highPart As Integer
Dim hBytes() As Byte
Dim valBytes(7) As Byte Dim longVal As Long
Dim largeIntType As Type largeIntType = largeInteger.GetType() Try
highPart = CType(largeIntType.InvokeMember("HighPart",
BindingFlags.GetProperty Or BindingFlags.Public, Nothing, largeInteger,
Nothing), Integer)
lowPart = CType(largeIntType.InvokeMember("LowPart",
BindingFlags.GetProperty Or BindingFlags.Public, Nothing, largeInteger,
Nothing), Integer) lBytes = BitConverter.GetBytes(lowPart)
hBytes = BitConverter.GetBytes(highPart) lBytes.CopyTo(valBytes, 0)
hBytes.CopyTo(valBytes, 4) longVal = BitConverter.ToInt64(valBytes, 0) Return longVal Catch e As MissingMethodException
Throw New ArgumentException("Invalid COM object passed as
parameter. Object must be IADsLargeInteger.", e)
End Try
End Function
注意要引入System.Reflection(using)
其中user是你的DirectoryEntry对象
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货