First, you will have to add a reference to the 'Active Directory DS' COM object.
Second, add the statement: using ActiveDS;
Here is a GroupNames() function to demo the process:
using ActiveDS;
public static string[] GroupNames(string userName)
{
List
if (String.IsNullOrEmpty(userName) == true)
{
return null;
}
userName = userName.Trim().Replace('\\', '/');
DirectoryEntry de = new DirectoryEntry(String.Format("WinNT://{0},user", userName));
IADsMembers groupsForUser = (IADsMembers) de.Invoke("Groups",null);
foreach (object group in groupsForUser)
{
DirectoryEntry deGroup = new DirectoryEntry(group);
result.Add(deGroup.Name);
}
if (result.Count == 0)
{
return null;
}
return result.ToArray();
}
2 comments:
Kyle great article about adsi! BTW do you have any good movie recommendation? Middle men was great!
Hey Kyle what are your thoughts on structural typing? The hip new languages golang and typescript do this and it looks like a nice design
Btw jason - scott is coming to cali next year and we’re planning a hiking camping napa trip. You shoukd join
Post a Comment