Files
Disco/Disco.Client/Interop/LocalAuthentication.cs
T
Gary Sharp 27c21175d7 Certificate/wireless plugins; major refactoring
Migrate much of BI to Services.
Added Wireless Profile Provider plugin feature.
Added Certificate Authority Provider plugin feature.
Modified Certificate Provider plugin feature.
Database migration v17, for Device Profiles.
Enrolment Client Updated to support CA Certificates, Wireless Profiles
and Hardware Info.
New Client Enrolment Protocol to support new features.
Plugin Manifest Generator added to main solution.
Improved AD search performance.
2016-09-28 20:17:55 +10:00

33 lines
1.1 KiB
C#

using System;
using System.Collections;
using System.DirectoryServices;
namespace Disco.Client.Interop
{
public static class LocalAuthentication
{
public static bool AddLocalGroupMembership(string GroupName, string UserSID, string Username, string UserDomain)
{
using (DirectoryEntry group = new DirectoryEntry($"WinNT://./{GroupName},group"))
{
// Check to see if the User is already a member
foreach (object memberRef in (IEnumerable)group.Invoke("Members"))
{
using (DirectoryEntry member = new DirectoryEntry(memberRef))
{
var memberPath = member.Path;
if (memberPath.Equals($"WinNT://{UserDomain}/{Username}", StringComparison.OrdinalIgnoreCase) ||
memberPath.Equals($"WinNT://{UserSID}", StringComparison.OrdinalIgnoreCase))
return false;
}
}
group.Invoke("Add", $"WinNT://{UserSID}");
}
return true;
}
}
}