久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在不使用 ActiveD 的情況下投射 ActiveDirectory pwdLa

Casting ActiveDirectory pwdLastSet property without using ActiveDs(在不使用 ActiveD 的情況下投射 ActiveDirectory pwdLastSet 屬性)
本文介紹了在不使用 ActiveD 的情況下投射 ActiveDirectory pwdLastSet 屬性的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

好的.所以我試圖找到一種方法來避免在我的項目中包含 ActiveD,因為我無法讓 dll 顯示在安裝程序中.擁有它的唯一原因是將 pwdLastSet 轉換為 LongInteger.

Ok. So I'm trying to find a way to avoid including ActiveDs in my project because I'm having trouble getting the dll to show up in the installer. The only reason to have it is to cast the pwdLastSet as a LongInteger.

我找到了一個無證替代品.測試它時,它要么完全開啟,要么關閉 429.49673 秒.我不知道為什么,有人知道嗎?(我測試的 20/49 人的時間為 429.49673 秒).

I found an undocumented alternative. When testing it, it is either dead on or 429.49673 seconds off. I'm not sure why, does anybody have any idea? (20/49 people that i tested are 429.49673 seconds off).

UPDATE:看起來像是 LowPart 為負時發生的.

UPDATE: It looks like it happens when the LowPart is negative.

代碼:

    private static string DateTest() {
        return DateTest(Environment.UserName);
    }
    private static string DateTest(string userName) {
        userName = userName.Trim();
        DateTime hacked, normal;
        using (DirectorySearcher ds = new DirectorySearcher()) {
            ds.SearchScope = SearchScope.Subtree;
            ds.PropertiesToLoad.Add("distinguishedName");
            ds.PropertiesToLoad.Add("pwdLastSet");
            ds.PageSize = 1;
            ds.ServerPageTimeLimit = TimeSpan.FromSeconds(2);
            ds.Filter = string.Format("(&(objectCategory=user)(sAMAccountName={0}))", userName);

            SearchResult sr = ds.FindOne();
            hacked = DateTime.FromFileTime((long)sr.Properties["pwdLastSet"][0]);

            using (DirectoryEntry user = sr.GetDirectoryEntry()) {
                var value = user.Properties["pwdLastSet"][0] as ActiveDs.LargeInteger;
                var longValue = (((long)value.HighPart) << 32) + (long)value.LowPart;
                normal = DateTime.FromFileTime(longValue);
            }
        }

        return string.Format("{3} - Difference: {0:0.0} seconds. Established Method returns: {1}. Hacked method returns: {2}",
            hacked.Subtract(normal).TotalSeconds, normal, hacked, userName);
    }
}

參考資料:

  • Active DS 類型庫
  • System.DirectoryServices

推薦答案

你需要像這樣翻譯 AD Long Integer 并且你不再需要 ActiveDs:

You'll need to translate the AD Long Integer like this and you shouldn't need ActiveDs anymore:

long pwdLastSet = CovertADSLargeIntegerToInt64(oUser.Properties["pwdLastSet"].Value);

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;
}

這篇關于在不使用 ActiveD 的情況下投射 ActiveDirectory pwdLastSet 屬性的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Why shouldn#39;t I always use nullable types in C#(為什么我不應該總是在 C# 中使用可空類型)
C# HasValue vs !=null(C# HasValue vs !=null)
C# ADO.NET: nulls and DbNull -- is there more efficient syntax?(C# ADO.NET:空值和 DbNull —— 有沒有更高效的語法?)
How to set null value to int in c#?(如何在c#中將空值設置為int?)
How to handle nulls in LINQ when using Min or Max?(使用 Min 或 Max 時如何處理 LINQ 中的空值?)
Method call if not null in C#(在 C# 中如果不為 null 的方法調用)
主站蜘蛛池模板: 精品一级 | 日一区二区 | 日韩欧美一区在线 | 国产日韩精品视频 | 正在播放国产精品 | 精品国产一区二区三区四区在线 | 在线播放第一页 | 男女爱爱福利视频 | 精品在线一区二区三区 | 四虎影视一区二区 | 一区二区av | 国产999精品久久久久久 | 黄色欧美在线 | 男女污污动态图 | 日本精品一区二区 | 天天欧美| 国产精品久久久久久av公交车 | 91资源在线 | 日韩中文字幕在线视频 | 日韩在线免费播放 | 欧洲成人免费视频 | jizz视频| 免费在线观看一区二区三区 | 国产xxxx搡xxxxx搡麻豆 | 中文字幕二区 | 四虎影院在线观看免费视频 | 高清视频一区二区三区 | 北条麻妃av一区二区三区 | 青青久久 | 在线激情视频 | 日韩欧美福利视频 | 超碰av人人| 成人在线视频观看 | 日日操操 | 久久乐国产精品 | 干干干操操操 | 殴美黄色录像 | 国产精品午夜电影 | 91精品国产91久久久久游泳池 | 欧美在线网站 | av电影手机版 |