I'm looking to extract a list of local groups and the users within each, rather than manually doing it. Additional information around permisisons (Rights & Views) would be a bonus but not vital.
Hi Ben,
You can extract the list of users and groups using the method mentioned in this other answer.
With the GetInfoMessage(InfoType.SecurityInfo) call, you can retrieve all users and all groups, and then perform a cross-reference of the data to determine the user's group.
In the end, you should have a method similar to the following snippet
var securityInfo = engine.SendSLNetSingleResponseMessage(new GetInfoMessage(InfoType.SecurityInfo)) as GetUserInfoResponseMessage;
Dictionary<int, string> groupNames = securityInfo.Groups.ToDictionary(g => g.ID, g => g.Name);
Dictionary<string, List<string>> groups = securityInfo.Groups.ToDictionary(g => g.Name, g => new List<string>());
foreach (var user in securityInfo.Users)
{
foreach (var userGroup in user.Groups)
{
if (groupNames.TryGetValue(userGroup, out var groupName))
{
groups[groupName].Add(user.FullName); // alternatively user.Name for username only
}
}
}
This should then allow you to write to a file or do anything you need with this information.