Exemplo n.º 1
0
        public bool ClearClosedAndDeletedTeamMailboxesInShowInMyClientList(ADUser userMailbox)
        {
            if (userMailbox == null)
            {
                throw new ArgumentNullException("userMailbox");
            }
            bool result            = false;
            List <ADObjectId> list = new List <ADObjectId>();

            foreach (ADObjectId item in userMailbox.TeamMailboxShowInClientList)
            {
                list.Add(item);
            }
            foreach (ADObjectId adobjectId in list)
            {
                Exception ex;
                ADUser    aduser = TeamMailboxADUserResolver.Resolve(this.DataSession, adobjectId, out ex);
                if (ex == null && (aduser == null || !TeamMailbox.FromDataObject(aduser).Active))
                {
                    userMailbox.TeamMailboxShowInClientList.Remove(adobjectId);
                    result = true;
                }
            }
            return(result);
        }
		public List<Exception> SendNotification(IList<ADObjectId> recipients, string subject, string body, RemotingOptions remotingOptons = RemotingOptions.LocalConnectionsOnly)
		{
			if (recipients == null)
			{
				throw new ArgumentNullException("recipients");
			}
			if (subject == null)
			{
				throw new ArgumentNullException("subject");
			}
			if (body == null)
			{
				throw new ArgumentNullException("body");
			}
			List<Exception> list = new List<Exception>();
			if (recipients.Count > 0)
			{
				using (MailboxSession mailboxSession = MailboxSession.OpenAsAdmin(ExchangePrincipal.FromADUser((ADUser)this.tm.DataObject, remotingOptons), CultureInfo.InvariantCulture, "Client=TeamMailbox;Action=Send_Notification"))
				{
					using (MessageItem messageItem = MessageItem.Create(mailboxSession, mailboxSession.GetDefaultFolderId(DefaultFolderType.Drafts)))
					{
						foreach (ADObjectId adobjectId in recipients)
						{
							Exception ex = null;
							ADUser aduser = TeamMailboxADUserResolver.Resolve(this.dataSession, adobjectId, out ex);
							if (ex != null)
							{
								list.Add(new Exception(string.Format("When resolving recipient {0}, got an excetion: {1}", adobjectId, ex)));
							}
							else if (aduser == null)
							{
								list.Add(new Exception("Cannot find recipient: " + adobjectId));
							}
							else
							{
								messageItem.Recipients.Add(new Participant(aduser.DisplayName, aduser.PrimarySmtpAddress.ToString(), "SMTP"));
							}
						}
						messageItem.Subject = subject;
						using (Stream stream = messageItem.Body.OpenWriteStream(new BodyWriteConfiguration(BodyFormat.TextHtml, Charset.Unicode)))
						{
							using (StreamWriter streamWriter = new StreamWriter(stream, Encoding.Unicode))
							{
								streamWriter.WriteLine(body);
							}
						}
						messageItem.AutoResponseSuppress = AutoResponseSuppress.All;
						messageItem.SendWithoutSavingMessage();
					}
				}
			}
			return list;
		}
Exemplo n.º 3
0
        private SecurityIdentifier GetUserSid(ADObjectId userId)
        {
            if (userId == null)
            {
                throw new ArgumentNullException("userId");
            }
            Exception ex;
            ADUser    aduser = TeamMailboxADUserResolver.Resolve(this.DataSession, userId, out ex);

            if (aduser == null)
            {
                return(null);
            }
            if (null != aduser.MasterAccountSid && !aduser.MasterAccountSid.IsWellKnown(WellKnownSidType.SelfSid))
            {
                return(aduser.MasterAccountSid);
            }
            return(aduser.Sid);
        }
Exemplo n.º 4
0
 public static ADUser ResolveBypassCache(IRecipientSession dataSession, ADObjectId id, out Exception ex)
 {
     TeamMailboxADUserResolver.RemoveIdIfExists(id);
     return(TeamMailboxADUserResolver.Resolve(dataSession, id, out ex));
 }
Exemplo n.º 5
0
 private ADUser ResolveUserFunction(ADObjectId id, out Exception ex)
 {
     return(TeamMailboxADUserResolver.Resolve(this.DataSession, id, out ex));
 }