简体   繁体   中英

To read the email adress assigned to an AD group Outlook 2010/Office 365

Office 365/Outlook 2010 Exchange Server, Outlook(2010) Plugin Dev.

Scenario:

The brief scenario is that in our organisation we have shared mailboxes that will be used by the users as primary email for communicating with the customers and one for handeling incoming emails. The user accounts have been created in the Active Directory (Cloud) where as the email accounts were created through the Office 365 Admin (Exchange Server) for the corresponding users.

The current Plugin reads through the AD and checks if the user is part of a certain group within the Active directory. Depending on the group it assigns the permissions whether the user can send emails On-Behalf of his/her manager or not. And in second case whether the user can send email only via shared mailbox (The shared mailbox supposed to act as primary account)

Please note that there are no email addresses assigned within the AD for the users. However what it should do is to read through the AD groups and fetch the email address that is assigned to that specific group (eg Sales). And that info should be in sync with Office 365.

The memembers of say "Sales" group are only eligible to send emails using that sharedmailbox (sales@domain.com) instead of their personal user account (thomas@domain.com). This condition is checked in the existing code however I don't see any implementation with respect to shared mailboxes instead it is on Regular mailbox named eg Sales@domain.com (Licensed account not a shared mailbox)

Is there a way that I can read through the AD groups and retrieve the corresponding shared mailbox addresses that are entered in the data field of the AD groups and hence apply further permissions on the users within a certain group?

Your help in this regard is highly appreciated!!

I have copied here the current query that is part of the Plugin that I am working on.

 bool QueryAD(string EMailAdresse, string Gruppe)  
 {
      PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
      GroupPrincipal grp = GroupPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, Gruppe);
      GroupMembershipCacheInitialized = true;

      if (grp != null)
      {
         foreach (Principal p in grp.GetMembers(false))
         {
          if (((UserPrincipal)p).EmailAddress == EMailAdresse) // this doesnt make sense because p.EmailAddress is always null
              {
                     GroupMembershipCache.Add(EMailAdresse, Gruppe);                        
                     return true;
              }
          }

         grp.Dispose();
         ctx.Dispose();
     }

     return false;
 }

You should be using the Microsoft Graph API . It is universal API for all Office 365 endpoints. If you are using Office 365 all your users will be part of the Azure AD domain.

Try the Microsoft Graph Explorer and Query the /Users endpoint like so:

https://graph.microsoft.com/v1.0/users

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM