Question: Subject: C# .NET You are developing a program that needs to find out the identity of the logged-in Windows user and the name of the
Subject: C# .NET
You are developing a program that needs to find out the identity of the logged-in Windows user and the name of the Windows Groups that the user is a member of. How would you write a program to retrieve this information?
This is what I have so far... getting error with last line of code "return user.isMemberOf(groups);" It's giving error "Argument 1: Cannot convert from PrincipalSearchResult
class Program { static void Main(string[] args) { string username; username = WindowsIdentity.GetCurrent().Name;
PrincipalContext context = new PrincipalContext(ContextType.Domain, "Domain");
//Find user UserPrincipal user = UserPrincipal.FindByIdentity(context, username);
//Find groups PrincipalSearchResult
if(user != null) { return user.IsMemberOf(groups); } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
