/// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            //Translate from bbCode to html
            Resources.BBCode bbc = new Resources.BBCode();
            DTO.Body = bbc.Transform(DTO.Body);

            List <string> groupCodes = new List <string>();

            GroupAccount_ADO gAdo = new GroupAccount_ADO();

            foreach (var code in DTO.GroupCodes)
            {
                groupCodes.Add(code.GrpCode);
            }

            //Get accounts associated with the Group(s)
            ADO_readerOutput readGroupAccounts = gAdo.ReadMultiple(Ado, groupCodes);

            Account_ADO      accAdo  = new Account_ADO();
            Account_DTO_Read dtoRead = new Account_DTO_Read();

            dtoRead.PrvCode = Resources.Constants.C_SECURITY_PRIVILEGE_POWER_USER;
            ADO_readerOutput readPowerUsers = accAdo.Read(Ado, dtoRead);

            //Get the AD data associated with the users, specifically
            ActiveDirectory_ADO adAdo = new ActiveDirectory_ADO();

            adAdo.MergeAdToUsers(ref readGroupAccounts);
            adAdo.MergeAdToUsers(ref readPowerUsers);

            eMail email = new eMail();

            if (!readGroupAccounts.hasData && !readPowerUsers.hasData)
            {
                Response.data = JSONRPC.success;
                Log.Instance.Debug("No email addresses found");
                return(true);
            }

            foreach (var user in readGroupAccounts.data)
            {
                email.Bcc.Add(user.CcnEmail.ToString());
            }

            foreach (var user in readPowerUsers.data)
            {
                email.Bcc.Add(user.CcnEmail.ToString());
            }


            email.Subject = DTO.Subject;
            email.Body    = DTO.Body;

            sendMail(email, Configuration_BSO.GetCustomConfig("title"), DTO.Subject, DTO.Body);

            Response.data = JSONRPC.success;
            return(true);
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        virtual protected bool IsUserAuthenticated()
        {
            if (Request.userPrincipal != null)
            {
                if (!ActiveDirectory.IsAuthenticated(Request.userPrincipal))
                {
                    OnAuthenticationFailed();
                    return(false);
                }

                //check in case the account is locked
                Account_ADO aAdo = new Account_ADO();

                ADO_readerOutput response = aAdo.Read(Ado, new Account_DTO_Read()
                {
                    CcnUsername = Request.userPrincipal.SamAccountName
                });
                if (!response.hasData)
                {
                    OnAuthenticationFailed();
                    return(false);
                }
                if (response.data[0].CcnLockedFlag)
                {
                    OnAuthenticationFailed();
                    return(false);
                }
                AuthenticationType = AuthenticationType.windows;
            }
            else
            {
                //This may be application authenticated, let's check..

                Response.error = null;

                if (Request.sessionCookie != null)
                {
                    //Does the cookie correspond with a live token for a user? If so then return the user.


                    ADO_readerOutput user;
                    using (Login_BSO lBso = new Login_BSO())
                    {
                        user = lBso.ReadBySession(Request.sessionCookie.Value);
                        if (!user.hasData)
                        {
                            Response.error = Label.Get("error.authentication");;
                            return(false);
                        }
                        else
                        {
                            SamAccountName = user.data[0].CcnUsername;
                            if (!HasUserPrivilege())
                            {
                                return(false);
                            }
                        }
                    }



                    AuthenticationType = AuthenticationType.local;
                }
                else
                {
                    return(false);
                }
            }

            OnAuthenticationSuccessful();
            return(true);
        }