For one of our customers, we have some functionality that creates a list of windows groups and the windows logins that are a member of these groups.
Before NAV 2013 we used system table 2000000052 - Windows Group Member for this. Unfortunately, in NAV 2013 this table has been removed.
Of course in NAV 2013 we have dotnet variables (
), so I've been googling for C# examples of how this is done, but I haven't gotten it to work within NAV yet.
Does anyone have a solution to find the windows groups and their users from within NAV 2013?
Answers
The tricky bit was converting the values from the PrincipalSearchResult to a type that can be read and understood by NAV. I've tried arrays and lists, but that doesn't work. Ultimately I tried creating an IEnumerator, which to my knowledge doesn't work in NAV 2009, and that works!
I've created the following DotNet variables:
And then the code for NAV is:
Thank you this has been very helpful. We have the same problem.
When I run your code, it lists all the entries in AD. I'm trying to figure out how to get just the SIDs for the current user (ie all the Windows Groups they belong to)
The goal is to see if a user has a specific role assigned, either directly to the user, or indirectly to a group they are part of. We're trying to reproduce the functionality of the "User SID" in 2009.
I hope that makes sense, if you know anything about it that would be awesome. I'm playing around with the various settings in those .NET objects and researching on the web but not getting to far yet.
- Reinhard
With the code I provided you get an insight in the Windows Groups and the Members of those Windows Groups. A member of a Windows Group can be another Windows Group or a Windows User. If you look into the members of the principals, you'll find the SamAccountName, which relates to the Windows User Name and the GUID, which I also found helpful.
You could loop over the principals and create an overview of which members belong to a group (top down) and then go backup through it per User to find the groups it is a member of.
Hope this helps!