by adam
7. September 2010 23:08
The code below will return all users on the machine that are not marked as disabled. Be sure to add a reference to System.DirectoryServices.
using System;
using System.Collections.Generic;
using System.DirectoryServices;
//...
private const int UF_ACCOUNTDISABLE = 0x0002;
private List<DirectoryEntry> GetActiveMachineUsers()
{
List<DirectoryEntry> returnValue = new List<DirectoryEntry>();
DirectoryEntry localMachine = new DirectoryEntry("WinNT://" + Environment.MachineName);
foreach (DirectoryEntry user in localMachine.Children)
{
if (user.SchemaClassName == "User")
{
if (((int)user.Properties["UserFlags"].Value & UF_ACCOUNTDISABLE) != UF_ACCOUNTDISABLE)
{
returnValue.Add(user);
}
}
}
return returnValue;
}

94c9afd8-8eba-4441-a279-aa2eb581345a|0|.0
Tags: c#, .net
.NET | C#
by adam
19. October 2009 10:43
Microsoft has made Visual Studio 2010 and .NET 4 beta 2 available today to MSDN subscribers with general availability on Wednesday (10/21).
Download the beta from: http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx
There are several new features available which you can read about at the following links:
Scott Guthrie has written several great posts detailing new features in Visual Studio 2010:
http://weblogs.asp.net/scottgu/archive/2009/08/25/vs-2010-and-net-4-series.aspx
What's new in ASP.NET 4.0 (Microsoft Whitepaper):
http://www.asp.net/learn/whitepapers/aspnet40/
Learning Resources for C# 4.0 and .NET 4.0:
http://bogdanbrinzarea.wordpress.com/2009/04/24/learning-net-40-new-features/
