private string GetRedirectServerFromMemberName(string memberName, out bool alreadyInTheRightForest, bool throwExceptionsOnTenantNotFound)
        {
            string address   = string.Format("E5CB63F56E8B4b69A1F70C192276D6AD@{0}", GlsDirectorySession.ParseMemberName(memberName).Domain);
            int    partnerId = MServDirectorySession.ReadMservEntry(address);

            return(this.GetRedirectServerFromPartnerId(partnerId, out alreadyInTheRightForest, throwExceptionsOnTenantNotFound));
        }
 internal static bool RemoveMserveEntry(string address, int value)
 {
     try
     {
         if (MServDirectorySession.RemoveMserveEntryWithExactValue(address, value))
         {
             return(true);
         }
     }
     catch (MServPermanentException)
     {
         ExTraceGlobals.MServTracer.TraceWarning <string, int>(0L, "Could not remove {0} with PartnerId {1}, will read the actual value now", address, value);
         value = MServDirectorySession.ReadMservEntry(address);
         if (value == -1)
         {
             ExTraceGlobals.MServTracer.TraceWarning <string>(0L, "Entry {0} does not exist, no need to remove", address);
             return(true);
         }
     }
     if (!MServDirectorySession.RemoveMserveEntryWithExactValue(address, value))
     {
         Globals.LogEvent(DirectoryEventLogConstants.Tuple_CannotDeleteMServEntry, address, new object[]
         {
             address
         });
         return(false);
     }
     return(true);
 }
        public string GetRedirectServer(Guid orgGuid)
        {
            string address   = string.Format("43BA6209CC0F4542958F65F8BF1CDED6@{0}.exchangereserved", orgGuid.ToString());
            int    partnerId = MServDirectorySession.ReadMservEntry(address);
            bool   flag;

            return(this.GetRedirectServerFromPartnerId(partnerId, out flag, true));
        }
        public bool TryGetRedirectServer(Guid orgGuid, out string fqdn)
        {
            string address   = string.Format("43BA6209CC0F4542958F65F8BF1CDED6@{0}.exchangereserved", orgGuid.ToString());
            int    partnerId = MServDirectorySession.ReadMservEntry(address);
            bool   flag;

            fqdn = this.GetRedirectServerFromPartnerId(partnerId, out flag, false);
            return(flag || string.Empty != fqdn);
        }
        private string GetResourceForestFqdnFromMservKey(string partnerIdEntryKey)
        {
            string result    = null;
            int    partnerId = MServDirectorySession.ReadMservEntry(partnerIdEntryKey);

            if (!this.TryGetForestFqdnFromPartnerId(partnerId, out result))
            {
                return(null);
            }
            return(result);
        }
        public bool TryGetDomainFlag(string domainFqdn, GlsDomainFlags flag, out bool value)
        {
            string address = MServDirectorySession.EntryIdForGlsDomainFlag(domainFqdn, flag);
            int    num     = MServDirectorySession.ReadMservEntry(address);

            if (num == -1)
            {
                value = false;
            }
            else
            {
                value = (num > 0);
            }
            return(true);
        }
        private int UpdateMservEntry(Guid externalDirectoryOrganizationId, bool allowOverwrite, string mservEntryKey)
        {
            int partnerId = this.GetLocalSite().PartnerId;
            int num       = MServDirectorySession.ReadMservEntry(mservEntryKey);

            if (num == -1)
            {
                MServDirectorySession.AddMserveEntry(mservEntryKey, partnerId);
            }
            else if (num != partnerId)
            {
                if (!allowOverwrite)
                {
                    throw new MServPermanentException(DirectoryStrings.TenantAlreadyExistsInMserv(externalDirectoryOrganizationId, num, partnerId));
                }
                MServDirectorySession.RemoveMserveEntry(mservEntryKey, num);
                MServDirectorySession.AddMserveEntry(mservEntryKey, partnerId);
            }
            return(num);
        }