2012-11-16 35 views
0

如何在程序上检测是否userAccount在本地操作系统中启用或禁用win xp或7(不是活动目录)。在C# 也如何检测userAccount通过是否过期?在C#Detect is userAccount在win xp或7 + C中启用或禁用#

谢谢。

+0

你的意思是,在登录窗口的时间? – Sohail

+0

为什么你甚至有这样的账户?这些是域控制器功能。 –

+0

不适用于stanalone应用程序。 –

回答

0
public static bool IsUserEnable(string username, ContextType type) 
     { 
      PrincipalContext context = new PrincipalContext(type); 
      UserPrincipal user = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, username); 

      return user.Enabled.Value; 
     } 

调用此方法,如:

IsUserEnable("guest", ContextType.Machine);