public static string GetProperty(SearchResult searchResult, string PropertyName)
{
if (searchResult.Properties.Contains(PropertyName))
{
return searchResult.Properties[PropertyName][0].ToString();
}
else
{
return string.Empty;
}
}
Il metodo di cui sopra funziona alla grande per più di Active Directory ad eccezione di quelli che sono legati alla data/ora come pwdLastSet, maxPwdAge, eccCome convertire pwdLastSet Active Directory per Data/Ora
La mia domanda è come ho la pwdLastSet a un datetime leggibile (come 2013/08/13 o 13 agosto, 2013, ecc)
ho tentativi questo, ma ha gettato eccezioni
public static Int64 ConvertADSLargeIntegerToInt64(object adsLargeInteger)
{
var highPart = (Int32)adsLargeInteger.GetType().InvokeMember("HighPart", System.Reflection.BindingFlags.GetProperty, null, adsLargeInteger, null);
var lowPart = (Int32)adsLargeInteger.GetType().InvokeMember("LowPart", System.Reflection.BindingFlags.GetProperty, null, adsLargeInteger, null);
return highPart * ((Int64)UInt32.MaxValue + 1) + lowPart;
}
sono u cantare il seguente codice per ottenere il tempo come un Int64
Int64 passwordLastSet = ConvertADSLargeIntegerToInt64(objResult.Properties["pwdLastSet"][0]);
Poi ho intenzione di utilizzare il DateTime (Int64) costruzione per creare un DateTime