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 errors with PrincipalContext, UserPrincipal, and GroupPrincipal.

static void Main(string[] args) { string UserId; UserId = WindowsIdentity.GetCurrent().Name;

PrincipalContext context = new PrincipalContext(ContextType.Domain, "Domain");

//Finding User UserPrincipal user = UserPrincipal.FindByIdentity(context, UserId);

//Finding Group GroupPrincipal group = GroupPrincipal.FindByIdentity(context, "Group Name");

if(user != null) { return user.IsMemberOf(group); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!