web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Development question Active Directory groups

(0) ShareShare
ReportReport
Posted on by 258

Hi Frnds,

I have a user (A) he has five group in ActiveDirectory (named AccounManager, BGroup, CGroup,..).  Whether the same AD group is  present in AX 2012? If so , how to check , assign and get roles for the same group in AX(which is already in AD). 

I can able to use the "System.DirectoryServices.AccountManagement" class to get the AD group for the user.

Here is my code to get the AD group  for the user:

domain = new System.DirectoryServices.AccountManagement.PrincipalContext(System.DirectoryServices.AccountManagement.ContextType::Domain);
networkAlias = userInfo.networkAlias;
//userPrinipal = System.DirectoryServices.AccountManagement.UserPrincipal::FindByIdentity(domain, networkAlias);
userPrinipal = System.DirectoryServices.AccountManagement.UserPrincipal::FindByIdentity(domain,networkAlias);
if(userPrinipal != null)
{
//groups = userPrinipal.GetAuthorizationGroups();
groups = userPrinipal.GetGroups();

enum = groups.GetEnumerator();
while (enum.MoveNext())
{
groupPrinipal = enum.get_Current();
groupName = groupPrinipal.get_Name();
groupN = groupName;

info(strFmt("Group 1 :%1 user id : %2 and user name %3",groupN,UserInfo.id,UserInfo.name));
}

Please check my code and correct me if anything wrong.

Here i have some question: 

What is the difference between this two group ?

groups = userPrinipal.GetAuthorizationGroups();
groups = userPrinipal.GetGroups();

.

Thanks in advance.

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,030 Super User 2025 Season 2 on at

    Hi Jackie,

    I have split this question as the question is different compared to the original. This would prevent changing the topic.

    You can get some information about the methods on MSDN:

    msdn.microsoft.com/.../system.directoryservices.accountmanagement.userprincipal.getgroups(v=vs.110).aspx

    msdn.microsoft.com/.../system.directoryservices.accountmanagement.userprincipal.getauthorizationgroups(v=vs.110).aspx

    The getGroups seems like returning only direct linked AD groups of a certain user. The GetAuthorizationGroups seems to be a method to get also indirectly assigned groups. But this is an AD related topic which is not my area of knowledge.

    I cannot comment on the code as you have not told the requirement to be fulfilled. Usually you setup the groups also as users in AX to have this feature enabled. I don't know your intention to read the AD groups per user.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans