none
Get Mailbox GUID/legacyExchangeDN through EWS or Powershell RRS feed

  • Question

  • Hi,

    I want to know if it's possible that given a mailbox's SMTP address or other attributes I can get the mailbox's GUID and/or legacyExchangeDN? EWS or Powershell can do that?

     

    Thanks

    Phil

    Wednesday, July 6, 2011 3:06 PM

All replies

  • Get-Mailbox harry.potter@hogwarts.edu | fl Name,ExchangeGuid,LegacyExchangeDN

     


    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
    Wednesday, July 6, 2011 3:42 PM
  • Thanks Ed for the PS script, does EWS give APIs for that?
    Wednesday, July 6, 2011 3:51 PM
  • IDK.  Perhaps someone else will chime in.  You might want to post that specific question in a new thread.
    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
    Thursday, July 7, 2011 3:18 AM
  • You can parse the LegacyDN out of the PR_STORE_ENTRYID extended property using EWS eg

          ExtendedPropertyDefinition PR_STORE_ENTRYID = new ExtendedPropertyDefinition(4091, MapiPropertyType.Binary);
          PropertySet psPropSet = new PropertySet(BasePropertySet.FirstClassProperties) { PR_STORE_ENTRYID };
          Folder Inbox = Folder.Bind(service, WellKnownFolderName.Inbox);
          Inbox.Load(psPropSet);
          object propVal = null;
          if (Inbox.TryGetProperty(PR_STORE_ENTRYID,out propVal))
          {
    
            byte[] ssStoreID = (byte[])propVal;
            int leLegDnStart = 0;
            String lnLegDN = "";
            for (int ssArraynum = (ssStoreID.Length - 2); ssArraynum != 0; ssArraynum--)
            {
              if (ssStoreID[ssArraynum] == 0)
              {
                leLegDnStart = ssArraynum;
                lnLegDN = System.Text.ASCIIEncoding.ASCII.GetString(ssStoreID, leLegDnStart + 1, (ssStoreID.Length - (leLegDnStart + 2)));
                ssArraynum = 1;
              }
            }
            Console.WriteLine(lnLegDN);
    

    Cheers
    Glen

    Thursday, July 7, 2011 5:50 AM
  • Thanks Glen, I also find that the LegacyDN can be got by the AutoDiscover.

    The mailbox GUID seems only available by Powershell, couldn't find anything in EWS for it, but I am not 100% sure. If someone can verify that it will be appreciated.

     

     

    Thursday, July 7, 2011 1:38 PM