惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

AI
AI
TaoSecurity Blog
TaoSecurity Blog
H
Heimdal Security Blog
Help Net Security
Help Net Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
N
News | PayPal Newsroom
V2EX - 技术
V2EX - 技术
博客园 - 【当耐特】
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
Secure Thoughts
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
有赞技术团队
有赞技术团队
S
Schneier on Security
S
SegmentFault 最新的问题
Google Online Security Blog
Google Online Security Blog
H
Hacker News: Front Page
The Last Watchdog
The Last Watchdog
Schneier on Security
Schneier on Security
PCI Perspectives
PCI Perspectives
IT之家
IT之家
Project Zero
Project Zero
博客园 - 司徒正美
P
Privacy International News Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Jina AI
Jina AI
Security Latest
Security Latest
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
V
Vulnerabilities – Threatpost
W
WeLiveSecurity
NISL@THU
NISL@THU
Webroot Blog
Webroot Blog
N
Netflix TechBlog - Medium
L
Lohrmann on Cybersecurity

博客园 - 花光月影

【转】如何通过mdf文件还原数据库的两种方法 PowerDesign的使用技巧 [转贴]SQL Server用户连接的管理 [转]程序设计中的感悟 几个开源的PORTAL sql2000中修改表的所有者的存储过程 [转]如何让你的SQL运行快起来,希望有所帮助 影响SQLSERVER的性能的一些指标 久不见矣 程序中无法获得Request.ServerVariables("HTTP_REFERER")的值,寻求解决方法~~~~ 农历年底大家都很忙吗? 数据库的安全策略 SQL 事件探查器术语 SQL2000滴系统存储过程--sp_changeobjectowner(更改当前数据库中对象的所有者) SQL学习笔记----SQL2000中的角色及功能 SQL数据库的事务日志意外增大或充满的处理方法 Sql Server数据库的备份和恢复措施 ASP调用.net的webservices的实现方法 ASP调用WebServices的方法?
.net中,如何获得活动目录(AD)上的密码失效时间?
花光月影 · 2005-10-21 · via 博客园 - 花光月影

博客园     首页     新随笔     新文章     联系    订阅 订阅     管理

据我所知,在.net没有方法直接通过获取属性的方法获得AD上密码失效的时间.要通过用户属性pwdLastSet(密码最后设置时间)和域属性maxPwdAge(密码最大寿命)这两个属性值计算获得.

pwdLastSet属性值可以通过如下代码获得,

但是怎么获得maxPwdAge这个属性值,请高手相助?

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Runtime.InteropServices;
using System.DirectoryServices;
namespace expiredate
{
    
/// 


    
/// WebForm1 的摘要说明。
    
/// 

    
///ActiveDs.tlb
    public class WebForm1 : System.Web.UI.Page
    
{        
        
protected System.Web.UI.WebControls.TextBox TextBox1;
        
protected System.Web.UI.WebControls.TextBox TextBox2;
        
protected System.Web.UI.WebControls.TextBox TextBox3;
        
protected System.Web.UI.WebControls.Button Button1;
        [ComImport]
        [Guid(
"9068270B-0939-11D1-8BE1-00C04FD8D503")]
        [InterfaceType(ComInterfaceType.InterfaceIsDual)]
        
internal interface IADsLargeInteger
        
{
            [DispId(
0x00000002)]
            
int HighPart...{getset;}
            [DispId(
0x00000003)]
            
int LowPart...{getset;}
        }

        
private void Button1_Click(object sender, System.EventArgs e)
        
{
            
string ADUser = "1111111111111";
            
string ADPassword = "22222222";
            
string ADPath="LDAP://....";    
            
try
            
{
                 System.DirectoryServices.DirectoryEntry mUser 
=
                                                                         new System.DirectoryServices.DirectoryEntry(ADPath,ADUser,ADPassword);
                 mUser.RefreshCache();
                 
if(mUser.Properties.Contains("pwdLastSet"))
                        
{                                           
                                  IADsLargeInteger li 
=(IADsLargeInteger)mUser.Properties["pwdLastSet"][0];              
                            
long date = (long)li.HighPart << 32 | (uint)li.LowPart;
                             DateTime time 
= DateTime.FromFileTime(date);
                            
this.TextBox1.Text=time.ToString();
                           }

                   }

          }

}


posted on 2005-10-21 15:22  花光月影  阅读(1583)  评论(3)    收藏  举报

刷新页面返回顶部