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

推荐订阅源

S
Secure Thoughts
罗磊的独立博客
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Last Week in AI
Last Week in AI
美团技术团队
Google Online Security Blog
Google Online Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
月光博客
月光博客
L
LINUX DO - 最新话题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
W
WeLiveSecurity
H
Heimdal Security Blog
Vercel News
Vercel News
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
A
About on SuperTechFans
C
Check Point Blog
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
AI
AI
WordPress大学
WordPress大学
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Help Net Security
Help Net Security
博客园_首页
The Last Watchdog
The Last Watchdog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
I
Intezer
K
Kaspersky official blog
M
MIT News - Artificial intelligence
J
Java Code Geeks
G
GRAHAM CLULEY
P
Palo Alto Networks Blog

博客园 - 花光月影

【转】如何通过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)    收藏  举报

刷新页面返回顶部