我正在尝试获取目录服务对象的"uSNChanged"值的Int64值.不幸的是,它总是以某种COM对象的形式回归.我尝试使用转换为Int64,调用Int64.Parse(),并调用Convert.ToInt64().这些都不起作用.
对于给定的DirectoryEntry对象,此代码将显示以下属性:
private static void DisplaySelectedProperties(DirectoryEntry objADObject)
{
try
{
string[] properties = new string[] {
"displayName",
"whenCreated",
"whenChanged",
"uSNCreated",
"uSNChanged",
};
Console.WriteLine(String.Format("Displaying selected properties of {0}", objADObject.Path));
foreach (string strAttrName in properties)
{
foreach (var objAttrValue in objADObject.Properties[strAttrName])
{
string strAttrValue = objAttrValue.ToString();
Console.WriteLine(String.Format(" {0, -22} : {1}", strAttrName, strAttrValue));
}
}
Console.WriteLine();
}
catch (Exception ex)
{
throw new ApplicationException(string.Format("Fatal error accessing: {0} - {1}", objADObject.Path, ex.Message), ex);
}
}
Run Code Online (Sandbox Code Playgroud)
这是输出:
Displaying selected properties of LDAP://server/o=org/cn=obj displayName : …