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

Announcements

News and Announcements icon
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
    305,849 Super User 2026 Season 1 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 10

#2
Harisgillani Profile Picture

Harisgillani 4

#2
dserp Profile Picture

dserp 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans