Пример #1
0
        /// <summary>
        /// Overloaded. Initialize instance of access object.
        /// </summary>
        /// <param name="credentials">CredentialsBase: Active credentials object.</param>
        /// <param name="token">string: Application token.</param>
        public Access(Credentials credentials, string token)
        {
             if (token.Length == 0)
                throw new System.ArgumentException("The application token [token] cannot be empty.");

            //  Set the properties
            _CurrentCredentials = credentials;
            _ApplicationToken = token;
        }
Пример #2
0
 /// <summary>
 /// Add new project role to the TACS.NET database.
 /// </summary>
 /// <param name="newRole">iCampaign.TACS.Role: object.</param>
 /// <param name="role">string: Caller role being used.</param>
 /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
 public void AddProjectRole(Role newRole, string role, Credentials credentials)
 {
     string result = String.Empty;
     ProjectServiceProxy.ProjectService projectService =
         new iCampaign.TACS.ProjectServiceProxy.ProjectService();
     try
     {
         result = projectService.AddRole(newRole, role, credentials);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     if (result != "OK")
     {
         throw new System.SystemException(result);
     }
 }
Пример #3
0
 /// <summary>
 /// Assign a project role to the specified user profile.
 /// </summary>
 /// <param name="username">string: Username.</param>
 /// <param name="roleId">long: Role id to assign.</param>
 /// <param name="role">string: Caller role being used.</param>
 /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
 public void AssignUserRole(string username, long roleId, string role, Credentials credentials)
 {
     string result = String.Empty;
     ProjectServiceProxy.ProjectService projectService =
         new iCampaign.TACS.ProjectServiceProxy.ProjectService();
     try
     {
         result = projectService.AddUserRole(username, roleId, role, credentials);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     if (result != "OK")
     {
         throw new System.SystemException(result);
     }
 }
Пример #4
0
        /// <summary>
        /// Add a new project to an account in the TACS.NET database.
        /// </summary>
        /// <param name="project">iCampaign.TACS.ProjectProfile: object.</param>
        /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
        /// <returns>string: Status message.</returns>
        internal string AddProject(ProjectProfile project, Credentials credentials)
        {
            bool errorStatus = false;
            string result = String.Empty;

            //  Check to see if user has sufficient privilege
            if (!credentials.AccountOwner)
            {
                result = TacsSession.MSG_INSUFPRIV;
                errorStatus = true;
            }

            //  If no error exists, create the database objects and insert the record
            if (!errorStatus)
            {
                Data.ProjectsDs.ProjectsDataTable projectTable =
                    new ProjectsDs.ProjectsDataTable();
                Data.ProjectsDs.ProjectsRow row = projectTable.NewProjectsRow();
                Data.ProjectsDsTableAdapters.ProjectsTableAdapter tableAdapter =
                    new iCampaign.TACS.Data.ProjectsDsTableAdapters.ProjectsTableAdapter();
                tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString);
                try
                {
                    tableAdapter.Connection.Open();
                    row.AcctId = credentials.AccountId;
                    row.AppCode = project.ApplicationCode;
                    row.ConnectorType = project.ConnectorType.ToString();
                    row.CreatedOn = DateTime.Now;
                    row.Database = project.Database;
                    row.DataSource = project.DataSource;
                    row.Password = project.Password;
                    row.Project = project.Project;
                    row.Username = project.Username;
                    projectTable.AddProjectsRow(row);
                    tableAdapter.Update(projectTable);
                }
                catch (Exception ex)
                {
                    errorStatus = true;
                    result = ex.Message;
                }
                finally
                {
                    tableAdapter.Connection.Close();
                }
            }

            if (!errorStatus)
                result = TacsSession.MSG_SUCCESS;
            return result;
        }
Пример #5
0
        /// <summary>
        /// Get list of user profiles for the account id specified in credentials.
        /// </summary>
        /// <param name="credential">iCampaign.TACS.Client.Credentials: object.</param>
        /// <returns>System.Collection.Generic.List T:iCampaign.TACS.UserProfile</returns>
        public List<UserProfile> GetUserProfiles(Credentials credential)
        {
            List<UserProfile> userProfiles = null;
            AccessServiceProxy.AccessService accessService =
                new iCampaign.TACS.AccessServiceProxy.AccessService();

            //  Call the service and request list of user profiles
            try
            {
                userProfiles = accessService.GetUserProfiles(credential);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return userProfiles;
        }
Пример #6
0
 /// <summary>
 /// Get the specified account profile from the TACS.NET database.  
 /// (Super Administrator only.)
 /// </summary>
 /// <param name="acctId">long: Account id.</param>
 /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
 /// <returns>iCampaign.TACS.AccountProfile</returns>
 public AccountProfile GetAccountProfile(long acctId, Credentials credentials)
 {
     AccountProfile profile = null;
     ProjectServiceProxy.ProjectService projectService =
         new iCampaign.TACS.ProjectServiceProxy.ProjectService();
     try
     {
         profile = projectService.GetAccountProfile(acctId, credentials);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return profile;
 }
Пример #7
0
        /// <summary>
        /// Add a new user profile to a TACS.NET account.
        /// </summary>
        /// <param name="user">string: Unique user name.</param>
        /// <param name="pass">string: Plaintext password.</param>
        /// <param name="name">string: Full name.</param>
        /// <param name="email">string: Email address.</param>
        /// <param name="expirey">DateTime: Expiration date.</param>
        /// <param name="owner">bool: Account owner flag.</param>
        /// <param name="superAdmin">bool: Super administrator flag.</param>
        /// <param name="role">string: Caller role being used.</param>
        /// <param name="credentials">iCampaign.TACS.Client.Credentials: Object.</param>
        public void AddUserProfile(string user, string pass, string name, string email, DateTime expirey,
            bool owner, bool superAdmin, string role, Credentials credentials)
        {
            string result = String.Empty;

            //  Use SOAP proxy to TACS.NET AccessService
            AccessServiceProxy.AccessService accessService =
                new iCampaign.TACS.AccessServiceProxy.AccessService();

            //  Try to add the user profile
            try
            {
                result = accessService.AddUser(user, Security.CreateHash(pass), name, email,
                    expirey, owner, superAdmin, role, credentials);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            //  Check result code, if not success then throw exception with message
            //  from service.
            if (result != "OK")
                throw new System.Exception(result);
        }
Пример #8
0
        /// <summary>
        /// Delete the specified user id from the TACS.NET user table.
        /// </summary>
        /// <param name="user">string: Username to delete.</param>
        /// <param name="role">string: Caller role being used.</param>
        /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
        /// <returns>string: Status code.</returns>
        public string DeleteUser(string user, string role, Credentials credentials)
        {
            bool errorStatus = false;
            string statusMsg = "";

            //  Check to see if user has sufficient access
            if (!credentials.HasAccess(role, AccessLevelEnum.Owner) &&
                !credentials.AccountOwner && !credentials.SuperAdministrator)
            {
                errorStatus = true;
                statusMsg = TacsSession.MSG_INSUFPRIV;
            }

            //  Check to see if requestor owns the username in profile
            if (TacsSession.GetUserAccountId(user) != credentials.AccountId)
            {
                errorStatus = true;
                statusMsg = TacsSession.MSG_USERWRONGACCT;
            }

            //  Check for valid session token
            if (!TacsSession.IsTokenValid(credentials.Username, credentials.SessionToken))
            {
                errorStatus = true;
                statusMsg = TacsSession.MSG_INVALSESS;
            }

            //  Check username to see if it exists
            if (!errorStatus)
            {
                if (!TacsSession.DoesUserExist(user))
                {
                    errorStatus = true;
                    statusMsg = TacsSession.MSG_USERNOEXIST;
                }
            }

            //  If no error has occurred go ahead and delete the user profile
            if (!errorStatus)
            {
                Data.UserDsTableAdapters.UsersTableAdapter tableAdapter =
                    new iCampaign.TACS.Data.UserDsTableAdapters.UsersTableAdapter();
                tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString);
                try
                {
                    tableAdapter.Connection.Open();
                    tableAdapter.DeleteAccountUser(user, credentials.AccountId);
                    statusMsg = TacsSession.MSG_SUCCESS;
                }
                catch (Exception ex)
                {
                    statusMsg = ex.StackTrace;
                }
                finally
                {
                    tableAdapter.Connection.Close();
                }
            }
            return statusMsg;
        }
Пример #9
0
        /// <summary>
        /// Returns the requested user profile from the TACS.NET user table.
        /// </summary>
        /// <param name="user">string: Username.</param>
        /// <param name="role">string: Caller role being used.</param>
        /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
        /// <returns>iCampaign.TACS.UserProfile</returns>
        public UserProfile GetUserProfile(string user, string role, Credentials credentials)
        {
            bool errorStatus = false;
            UserProfile userProfile = new UserProfile();

            //  Check to see if user has sufficient access
            if (!credentials.HasAccess(role, AccessLevelEnum.Owner) && user != credentials.Username &&
                !credentials.AccountOwner && !credentials.SuperAdministrator)
            {
                errorStatus = true;
                userProfile.ErrorMessage = TacsSession.MSG_INSUFPRIV;
            }

            //  Check to see if requestor owns the username in profile
            if (TacsSession.GetUserAccountId(user) != credentials.AccountId)
            {
                errorStatus = true;
                userProfile.ErrorMessage = TacsSession.MSG_USERWRONGACCT;
            }

            //  Get the user profile
            if (!errorStatus)
            {
                Data.UserDs.UsersDataTable userTable = new UserDs.UsersDataTable();
                Data.UserDs.UsersRow userRow = null;
                Data.UserDsTableAdapters.UsersTableAdapter tableAdapter =
                    new iCampaign.TACS.Data.UserDsTableAdapters.UsersTableAdapter();
                tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString);
                try
                {
                    tableAdapter.Connection.Open();
                    tableAdapter.FillByUsername(userTable, user);
                    if (userTable.Rows.Count != 0)
                    {
                        userRow = userTable[0];
                    }
                    else
                    {
                        userProfile.ErrorMessage = TacsSession.MSG_UNKUSER;
                        errorStatus = true;
                    }
                }
                catch (Exception ex)
                {
                    errorStatus = true;
                    userProfile.ErrorMessage = ex.StackTrace;
                }
                finally
                {
                    tableAdapter.Connection.Close();
                }
                if (!errorStatus)
                {
                    userProfile.Username = userRow.Username;
                    userProfile.AccountId = userRow.AcctId;
                    userProfile.CreatedOn = userRow.CreatedOn;
                    userProfile.Email = userRow.Email;
                    userProfile.FullName = userRow.FullName;
                    userProfile.ErrorMessage = TacsSession.MSG_SUCCESS;
                    userProfile.UserExpirey = userRow.ExpireOn;
                    userProfile.Disable = userRow.UserDisabled;
                    userProfile.Password = userRow.Password;
                }

            }
            return userProfile;
        }
Пример #10
0
        /// <summary>
        /// Get an account profile registered in TACS.NET database.
        /// </summary>
        /// <param name="acctId">long: Account id.</param>
        /// <param name="credentials">iCamapaign.TACS.Client.Credentials: object.</param>
        /// <returns>System.Collections.Generic.List T:iCampaign.TACS.AccountProfile</returns>
        internal AccountProfile GetAccountProfile(long acctId, Credentials credentials)
        {
            AccountProfile profile = null;

            //  Check to see if user has sufficient access
            if (!credentials.SuperAdministrator)
            {
                throw new System.Exception(TacsSession.MSG_INSUFPRIV);
            }

            //  Check for valid session token
            if (!TacsSession.IsTokenValid(credentials.Username, credentials.SessionToken))
            {
                throw new System.Exception(TacsSession.MSG_INVALSESS);
            }

            //  Retrieve the list of account profiles from the database
            Data.AccountsDs.AccountsDataTable dataTable = new AccountsDs.AccountsDataTable();
            Data.AccountsDsTableAdapters.AccountsTableAdapter tableAdapter =
                new iCampaign.TACS.Data.AccountsDsTableAdapters.AccountsTableAdapter();
            tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString);
            try
            {
                tableAdapter.Connection.Open();
                tableAdapter.FillByAcctId(dataTable, acctId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                tableAdapter.Connection.Close();
            }

            //  Transfer data from data table to list collection
            Data.AccountsDs.AccountsRow row = dataTable[0];
            profile.Account = row.AcctName;
            profile.AccountId = row.AcctId;
            profile.Address1 = row.Address1;
            profile.Address2 = row.Address2;
            profile.City = row.City;
            profile.Contact = row.Contact;
            profile.CreatedOn = row.CreatedOn;
            profile.Email = row.Email;
            profile.ExpireOn = row.ExpireOn;
            profile.Phone = row.Phone;
            profile.State = row.State;
            profile.ZipCode = row.ZipCode;
            return profile;
        }
Пример #11
0
        /// <summary>
        /// Add a new user profile to a TACS.NET account.
        /// </summary>
        /// <param name="user">string: Unique user name.</param>
        /// <param name="pass">string: Encrypted password.</param>
        /// <param name="name">string: Full name.</param>
        /// <param name="email">string: Email address.</param>
        /// <param name="expirey">DateTime: Expiration date.</param>
        /// <param name="owner">bool: Account owner flag.</param>
        /// <param name="superAdmin">bool: Super administrator flag.</param>
        /// <param name="role">string: Caller role being used.</param>
        /// <param name="credentials">iCampaign.TACS.Client.Credentials: Object.</param>
        /// <returns>string: Status code.</returns>
        public string AddUser(string user, string pass, string name, string email, DateTime expirey,
            bool owner, bool superAdmin, string role, Credentials credentials)
        {
            bool errorStatus = false;
            string statusMsg = "";

            //  Check to see if user has sufficient access
            if (!credentials.HasAccess(role, AccessLevelEnum.Owner) &&
                !credentials.AccountOwner && !credentials.SuperAdministrator)
            {
                errorStatus = true;
                statusMsg = TacsSession.MSG_INSUFPRIV;
            }

            //  Check for valid session token
            if (!TacsSession.IsTokenValid(credentials.Username, credentials.SessionToken))
            {
                errorStatus = true;
                statusMsg = TacsSession.MSG_INVALSESS;
            }

            //  Check to see if new account is a super admin
            if (superAdmin == true && credentials.SuperAdministrator == false)
            {
                errorStatus = true;
                statusMsg = TacsSession.MSG_SUPERONLY;
            }

            //  Check username to see if it exists
            if (!errorStatus)
            {
                if (TacsSession.DoesUserExist(user) == true)
                {
                    errorStatus = true;
                    statusMsg = TacsSession.MSG_USEREXISTS;
                }
            }

            //  Create the user profile
            if (!errorStatus)
            {
                //  Instantiate ADO.NET objects
                Data.UserDs.UsersDataTable userTable = new UserDs.UsersDataTable();
                Data.UserDs.UsersRow userRow = userTable.NewUsersRow();
                Data.UserDsTableAdapters.UsersTableAdapter tableAdapter =
                    new iCampaign.TACS.Data.UserDsTableAdapters.UsersTableAdapter();
                tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString);

                //  Build the new user profile
                userRow.AcctId = credentials.AccountId;
                userRow.CreatedOn = System.DateTime.Now;
                userRow.Email = email;
                userRow.ExpireOn = expirey;
                userRow.FullName = name;
                userRow.Password = pass;
                userRow.UserDisabled = false;
                userRow.Username = user;
                userRow.AccountOwner = owner;
                userRow.SuperAdministrator = superAdmin;
                userTable.AddUsersRow(userRow);

                //  Add the record to the database
                try
                {
                    tableAdapter.Connection.Open();
                    tableAdapter.Update(userTable);
                    statusMsg = TacsSession.MSG_SUCCESS;
                }
                catch (Exception ex)
                {
                    statusMsg = ex.StackTrace;
                    errorStatus = true;
                }
                finally
                {
                    tableAdapter.Connection.Close();
                }
            }
            return statusMsg;
        }
Пример #12
0
        /// <summary>
        /// Get a list of accounts registered in TACS.NET database.
        /// </summary>
        /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
        /// <returns>System.Collections.Generic.List T:string</returns>
        internal List<string> GetAccounts(Credentials credentials)
        {
            List<string> resultList = new List<string>();

            //  Check to see if user has sufficient access
            if (!credentials.SuperAdministrator)
            {
                throw new System.Exception(TacsSession.MSG_INSUFPRIV);
            }

            //  Check for valid session token
            if (!TacsSession.IsTokenValid(credentials.Username, credentials.SessionToken))
            {
                throw new System.Exception(TacsSession.MSG_INVALSESS);
            }

            //  Get the list of accounts from the database
            Data.AccountsDs.AccountsDataTable dataTable = new AccountsDs.AccountsDataTable();
            Data.AccountsDsTableAdapters.AccountsTableAdapter tableAdapter =
                new iCampaign.TACS.Data.AccountsDsTableAdapters.AccountsTableAdapter();
            tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString);
            try
            {
                tableAdapter.Connection.Open();
                tableAdapter.Fill(dataTable);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                tableAdapter.Connection.Close();
            }

            //  Copy the data table to a list collection
            foreach (Data.AccountsDs.AccountsRow row in dataTable)
            {
                resultList.Add(row.AcctName);
            }
            return resultList;
        }
Пример #13
0
        /// <summary>
        /// Assign a project role to specified user profile.
        /// </summary>
        /// <param name="username">string: Username to assign.</param>
        /// <param name="roleId">long: Role id to assign.</param>
        /// <param name="role">string: Caller role being used.</param>
        /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
        /// <returns>string: Status message.</returns>
        public string AddUserRole(string username, long roleId, string role, Credentials credentials)
        {
            bool errorStatus = false;
            string result = String.Empty;

            //  Check to see if user has sufficient access
            if (!credentials.HasAccess(role, AccessLevelEnum.Owner) || credentials.AccountOwner)
            {
                errorStatus = true;
                result = TacsSession.MSG_INSUFPRIV;
            }

            //  Check for valid session token
            if (!TacsSession.IsTokenValid(credentials.Username, credentials.SessionToken))
            {
                errorStatus = true;
                result = TacsSession.MSG_INVALSESS;
            }

            //  If no error condition exists, add go ahead and assign the user roles
            if (!errorStatus)
            {
                Data.UserProjectsDs.UserProjectsDataTable dataTable =
                    new UserProjectsDs.UserProjectsDataTable();
                Data.UserProjectsDs.UserProjectsRow dataRow = dataTable.NewUserProjectsRow();
                Data.UserProjectsDsTableAdapters.UserProjectsTableAdapter tableAdapter =
                    new iCampaign.TACS.Data.UserProjectsDsTableAdapters.UserProjectsTableAdapter();
                tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString);
                try
                {
                    dataRow.CreatedOn = System.DateTime.Now;
                    dataRow.RoleId = roleId;
                    dataRow.Project = credentials.Project;
                    dataRow.Username = username;
                    dataTable.AddUserProjectsRow(dataRow);
                    tableAdapter.Connection.Open();
                    tableAdapter.Update(dataTable);
                    result = TacsSession.MSG_SUCCESS;
                }
                catch (Exception ex)
                {
                    errorStatus = true;
                    result = ex.Message;
                }
                finally
                {
                    tableAdapter.Connection.Close();
                }
            }
            return result;
        }
Пример #14
0
        /// <summary>
        /// Add a new security role to the specified project.
        /// </summary>
        /// <param name="newRole">iCampaign.TACS.Role: object.</param>
        /// <param name="role">string: Caller role being used.</param>
        /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
        public string AddRole(Role newRole, string role, Credentials credentials)
        {
            string result = String.Empty;
            bool errorStatus = false;

            //  Check to see if user has sufficient access
            if (!credentials.HasAccess(role, AccessLevelEnum.Owner) || credentials.AccountOwner)
            {
                errorStatus = true;
                result = TacsSession.MSG_INSUFPRIV;
            }

            //  Check for valid session token
            if (!TacsSession.IsTokenValid(credentials.Username, credentials.SessionToken))
            {
                errorStatus = true;
                result = TacsSession.MSG_INVALSESS;
            }

            //  Verify that a role name was provided
            if (newRole.Name.Length == 0)
            {
                errorStatus = true;
                result = TacsSession.MSG_INVALROLE;
            }

            //  If no error condition exists, go ahead and add the new role
            if (!errorStatus)
            {
                Data.RolesDs.RolesDataTable rolesTable = new RolesDs.RolesDataTable();
                Data.RolesDs.RolesRow rolesRow = rolesTable.NewRolesRow();
                Data.RolesDsTableAdapters.RolesTableAdapter tableAdapter =
                    new iCampaign.TACS.Data.RolesDsTableAdapters.RolesTableAdapter();
                tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString);
                try
                {
                    rolesRow.RoleName = newRole.Name;
                    rolesRow.AccessLevel = (int)newRole.AccessLevel;
                    rolesTable.AddRolesRow(rolesRow);
                    tableAdapter.Connection.Open();
                    tableAdapter.Update(rolesTable);
                    result = TacsSession.MSG_SUCCESS;
                }
                catch (Exception ex)
                {
                    errorStatus = true;
                    result = ex.Message;
                }
                finally
                {
                    tableAdapter.Connection.Close();
                }
            }

            return result;
        }
Пример #15
0
 /// <summary>
 /// Get list of registered accounts from TACS.NET database.
 /// (Super Administrator only.)
 /// </summary>
 /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
 /// <returns>System.Collections.Generic.List T:string</returns>
 public List<string> GetAccounts(Credentials credentials)
 {
     List<string> resultList = null;
     ProjectServiceProxy.ProjectService projectService =
         new iCampaign.TACS.ProjectServiceProxy.ProjectService();
     try
     {
         resultList = projectService.GetAccounts(credentials);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return resultList;
 }
Пример #16
0
        /// <summary>
        /// Provides login authentication for iCampaign application returning the user
        /// access credentials.
        /// </summary>
        /// <param name="project">string: Project name.</param>
        /// <param name="user">string: User name.</param>
        /// <param name="encpass">string: Encrypted password.</param>
        /// <param name="appcode">string: Application code.</param>
        /// <returns>iCampaign.TACS.Client.Credentials: object.</returns>
        public Credentials Login(string project, string user, string encpass, string appcode)
        {
            bool errorStatus = false;

            //  Instantiate objects required for this method
            Credentials myCredentials = null;
            UserProfile userProfile = new UserProfile();

            //  Validate the application code
            if (!TacsSession.IsAppValid(appcode))
            {
                myCredentials = new Credentials(TacsSession.MSG_INVALIDAPP);
                errorStatus = true;
            }

            //  Validate the project
            if (!errorStatus)
            {
                if (!TacsSession.IsProjectValid(appcode, project))
                {
                    myCredentials = new Credentials(TacsSession.MSG_UNKPROJECT);
                    errorStatus = true;
                }
            }

            //  Authenticate the login request
            if (!errorStatus)
            {
                Data.AccessViewDs.AccessViewDataTable accessTable = new AccessViewDs.AccessViewDataTable();
                Data.AccessViewDsTableAdapters.AccessViewTableAdapter tableAdapter =
                    new iCampaign.TACS.Data.AccessViewDsTableAdapters.AccessViewTableAdapter();
                tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString);
                Data.AccessViewDs.AccessViewRow accessRow = null;
                try
                {
                    tableAdapter.Connection.Open();
                    if (tableAdapter.FillByLogin(accessTable, project, user, encpass) == 0)
                    {
                        //  Username or password is invalid so set error message
                        myCredentials = new Credentials(TacsSession.MSG_INVALIDPASS);
                        errorStatus = true;
                    }
                    else
                    {
                        //  User profile found so set row object
                        accessRow = accessTable[0];
                    }
                }
                catch (Exception ex)
                {
                    //  An exception occurred so send stack trace back
                    myCredentials = new Credentials(ex.Message);
                    errorStatus = true;
                    TacsSession.WriteEventLogEntry("AccessService", EventTypeEnum.Error,
                        ex.Message + " " + ex.StackTrace);
                }
                finally
                {
                    tableAdapter.Connection.Close();
                }
                //  If no error has occurred go ahead and check account status
                if (!errorStatus)
                {
                    //  Check for account expiration
                    if (accessRow.AcctExpirey < System.DateTime.Now)
                    {
                        myCredentials = new Credentials(TacsSession.MSG_ACCTDISABLED);
                        errorStatus = true;
                    }
                    //  Check for user profile expiration or disabled flag
                    if (accessRow.UserExpirey < System.DateTime.Now || accessRow.UserDisabled)
                    {
                        myCredentials = new Credentials(TacsSession.MSG_USERDISABLED);
                        errorStatus = true;
                    }
                }
                //  If no error has occurred go ahead and build user profile
                if (!errorStatus)
                {
                    userProfile.AccountExpirey = accessRow.AcctExpirey;
                    userProfile.AccountId = accessRow.AcctId;
                    userProfile.AccountName = accessRow.AcctName;
                    userProfile.ConnectorType = TacsSession.GetConnectorType(accessRow.ConnectorType);
                    userProfile.Database = accessRow.Database;
                    userProfile.DataSource = accessRow.DataSource;
                    userProfile.Disable = accessRow.UserDisabled;
                    userProfile.Email = accessRow.Email;
                    userProfile.ErrorMessage = TacsSession.MSG_SUCCESS;
                    userProfile.FullName = accessRow.FullName;
                    userProfile.Project = accessRow.Project;
                    userProfile.SqlPassword = accessRow.DbPassword;
                    userProfile.SqlUser = accessRow.DbUsername;
                    userProfile.UserExpirey = accessRow.UserExpirey;
                    userProfile.Username = accessRow.Username;
                    userProfile.AccountOwner = accessRow.AccountOwner;
                    userProfile.SuperAdministrator = accessRow.SuperAdministrator;

                    //  Get the security roles
                    try
                    {
                        userProfile.Roles = GetRoles(project, user);
                    }
                    catch (Exception ex)
                    {
                        myCredentials = new Credentials(ex.Message);
                        errorStatus = true;
                        TacsSession.WriteEventLogEntry("AccessService", EventTypeEnum.Error,
                        ex.Message + " " + ex.StackTrace);
                    }
                }

                //  If no error occurred go ahead and get application info
                if (!errorStatus)
                {
                    try
                    {
                        Data.ApplicationsDs.ApplicationsRow appRow =
                            GetApplicationRow(appcode);
                        userProfile.ApplicationCode = appcode;
                        userProfile.ApplicationGUID = appRow.AppGuid;
                        userProfile.DownloadURL = appRow.DownloadURL;
                    }
                    catch (Exception ex)
                    {
                        myCredentials = new Credentials(ex.Message);
                        errorStatus = true;
                        TacsSession.WriteEventLogEntry("AccessService", EventTypeEnum.Error,
                        ex.Message + " " + ex.StackTrace);
                    }
                }

                //  If no error occurred go ahead and create the session token
                if (!errorStatus)
                {
                    try
                    {
                        userProfile.SessionToken = SetSessionToken(user);
                    }
                    catch (Exception ex)
                    {
                        myCredentials = new Credentials(ex.Message);
                        errorStatus = true;
                        TacsSession.WriteEventLogEntry("AccessService", EventTypeEnum.Error,
                        ex.Message + " " + ex.StackTrace);
                    }
                }

                //  If no error occurred go ahead and create the credentials object
                if (!errorStatus)
                {
                    myCredentials = new Credentials(userProfile);
                    TacsSession.WriteEventLogEntry("Login", EventTypeEnum.Information,
                        myCredentials.Username + " successfully logged in.");
                }
                else
                {
                    TacsSession.WriteEventLogEntry("AccessService", EventTypeEnum.Warning,
                        myCredentials.Username + " login failed.");
                }
            }
            return myCredentials;
        }
Пример #17
0
 /// <summary>
 /// Get list of account profiles registered in the TACS.NET database.  
 /// (Super Administrator only.)
 /// </summary>
 /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
 /// <returns>System.Collections.Generic.List T:iCampaign.TACS.AccountProfile</returns>
 public List<AccountProfile> GetAccountProfiles(Credentials credentials)
 {
     List<AccountProfile> profileList = null;
     ProjectServiceProxy.ProjectService projectService =
         new iCampaign.TACS.ProjectServiceProxy.ProjectService();
     try
     {
         profileList = projectService.GetAccountProfiles(credentials);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return profileList;
 }
Пример #18
0
        /// <summary>
        /// Updates the provided user profile in the TACS.NET user table.
        /// </summary>
        /// <param name="profile">iCampaign.TACS.UserProfile: object.</param>
        /// <param name="role">string: Caller role being used.</param>
        /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
        /// <returns>Status code</returns>
        public string UpdateUser(UserProfile profile, string role, Credentials credentials)
        {
            bool errorStatus = false;
            string statusMsg = "";

            //  Check to see if user has sufficient access
            if (!credentials.HasAccess(role, AccessLevelEnum.Owner) &&
                !credentials.AccountOwner && !credentials.SuperAdministrator)
            {
                errorStatus = true;
                statusMsg = TacsSession.MSG_INSUFPRIV;
            }

            //  Check to see if requestor owns the username in profile
            if (TacsSession.GetUserAccountId(profile.Username) != credentials.AccountId)
            {
                errorStatus = true;
                statusMsg = TacsSession.MSG_USERWRONGACCT;
            }

            //  Check for valid session token
            if (!TacsSession.IsTokenValid(credentials.Username, credentials.SessionToken))
            {
                errorStatus = true;
                statusMsg = TacsSession.MSG_INVALSESS;
            }

            //  Check for super administrator being set
            if (profile.SuperAdministrator == true && credentials.SuperAdministrator == false)
            {
                errorStatus = true;
                statusMsg = TacsSession.MSG_SUPERONLY;
            }

            //  Check username to see if it exists
            if (!errorStatus)
            {
                if (!TacsSession.DoesUserExist(profile.Username))
                {
                    errorStatus = true;
                    statusMsg = TacsSession.MSG_USERNOEXIST;
                }
            }

            //  If no error condition exists, go ahead and update database
            if (!errorStatus)
            {
                Data.UserDsTableAdapters.UsersTableAdapter tableAdapter =
                    new iCampaign.TACS.Data.UserDsTableAdapters.UsersTableAdapter();
                tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString);
                try
                {
                    tableAdapter.Connection.Open();
                    tableAdapter.UpdateUserProfile(profile.Username, profile.Password, profile.FullName,
                        profile.Email, profile.CreatedOn, profile.UserExpirey, profile.Disable,
                        profile.SessionToken, profile.AccountId, profile.AccountOwner, profile.SuperAdministrator, profile.Username);
                    statusMsg = TacsSession.MSG_SUCCESS;
                }
                catch (Exception ex)
                {
                    errorStatus = true;
                    statusMsg = ex.Message;
                }
                finally
                {
                    tableAdapter.Connection.Close();
                }
            }
            return statusMsg;
        }
Пример #19
0
 /// <summary>
 /// Get a list of projects owned by the specified account.
 /// </summary>
 /// <param name="acctId">long: Account id.</param>
 /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
 /// <returns>System.Collections.Generic.List T:string</returns>
 public List<string> GetProjectsByAccount(long acctId, Credentials credentials)
 {
     List<string> projectList = new List<string>();
     ProjectServiceProxy.ProjectService projectService =
         new iCampaign.TACS.ProjectServiceProxy.ProjectService();
     try
     {
         projectList = projectService.GetProjectsByAcct(acctId);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return projectList;
 }
Пример #20
0
        /// <summary>
        /// Publishes list of user profiles for account id specified in Credentials.
        /// </summary>
        /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
        /// <returns>System.Collections.Generic.List T:iCampaign.TACS.UserProfile</returns>
        public List<UserProfile> GetUserProfiles(Credentials credentials)
        {
            List<UserProfile> userProfiles = new List<UserProfile>();

            //  Check to see if user has sufficient access
            if (!credentials.AccountOwner)
            {
                throw new SystemException(TacsSession.MSG_INSUFPRIV);
            }

            //  Check for valid session token
            if (!TacsSession.IsTokenValid(credentials.Username, credentials.SessionToken))
            {
                throw new SystemException(TacsSession.MSG_INVALSESS);
            }

            //  Go and retrieve the list of user profiles
            Data.UserDs.UsersDataTable dataTable = new UserDs.UsersDataTable();
            Data.UserDsTableAdapters.UsersTableAdapter tableAdapter =
                new iCampaign.TACS.Data.UserDsTableAdapters.UsersTableAdapter();
            tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString);
            try
            {
                tableAdapter.Connection.Open();
                tableAdapter.FillByAcctId(dataTable, credentials.AccountId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                tableAdapter.Connection.Close();
            }

            //  Now populate the list collection from the data table
            foreach (Data.UserDs.UsersRow row in dataTable)
            {
                UserProfile profile = new UserProfile();
                profile.AccountExpirey = row.ExpireOn;
                profile.AccountId = row.AcctId;
                profile.AccountName = credentials.AccountName;
                profile.AccountOwner = row.AccountOwner;
                profile.Disable = row.UserDisabled;
                profile.Email = row.Email;
                profile.FullName = row.FullName;
                profile.Password = row.Password;
                profile.SuperAdministrator = row.SuperAdministrator;
                userProfiles.Add(profile);
            }

            return userProfiles;
        }
Пример #21
0
 /// <summary>
 /// Reset user password in TACS.NET database.
 /// </summary>
 /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
 /// <param name="plainpass">string: Plain text password.</param>
 public void ResetPassword(Credentials credentials, string plainpass)
 {
     AccessServiceProxy.AccessService accessService =
         new iCampaign.TACS.AccessServiceProxy.AccessService();
     try
     {
         accessService.ResetPassword(credentials, Security.CreateHash(plainpass));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #22
0
        /// <summary>
        /// Reset the password of the specified user in the TACS.NET database.
        /// </summary>
        /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
        /// <param name="encpass">string: Encrypted password.</param>
        public void ResetPassword(Credentials credentials, string encpass)
        {
            //  Check the session token first
            if (!TacsSession.IsTokenValid(credentials.Username, credentials.SessionToken))
                throw new System.Exception(TacsSession.MSG_INVALSESS);

            //  Reset the password
            Data.UserDsTableAdapters.UsersTableAdapter tableAdapter =
                new iCampaign.TACS.Data.UserDsTableAdapters.UsersTableAdapter();
            tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString);
            try
            {
                tableAdapter.Connection.Open();
                tableAdapter.ResetPassword(encpass, credentials.Username);
            }
            catch (Exception ex)
            {
                TacsSession.WriteEventLogEntry("AccessService", EventTypeEnum.Error,
                    "ResetPassword: " + ex.Message);
                throw ex;
            }
            finally
            {
                tableAdapter.Connection.Close();
            }
        }
Пример #23
0
        /// <summary>
        /// Update the specified user profile in the TACS.NET database.
        /// </summary>
        /// <param name="profile">iCampaign.TACS.Profile: object.</param>
        /// <param name="role">string: Caller role being used.</param>
        /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
        public void UpdateUserProfile(UserProfile profile, string role, Credentials credentials)
        {
            string result = String.Empty;
            AccessServiceProxy.AccessService accessService =
                new iCampaign.TACS.AccessServiceProxy.AccessService();
            try
            {
                result = accessService.UpdateUser(profile, role, credentials);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            //  Check the result message
            if (result != "OK")
                throw new System.Exception(result);
        }
Пример #24
0
 /// <summary>
 /// Get the specified project profile from the TACS.NET database.
 /// </summary>
 /// <param name="project">string: Project name.</param>
 /// <param name="role">string: Caller role being used.</param>
 /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
 /// <returns>iCampaign.TACS.ProjectProfile: object.</returns>
 public ProjectProfile GetProjectProfile(string project, string role,
     Credentials credentials)
 {
     ProjectProfile result = null;
     ProjectServiceProxy.ProjectService projectService =
         new iCampaign.TACS.ProjectServiceProxy.ProjectService();
     try
     {
         result = projectService.GetProject(project, role, credentials);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return result;
 }
Пример #25
0
        /// <summary>
        /// Returns the TACS.NET credentials based on the user's login information.
        /// </summary>
        /// <param name="project">string: Project name.</param>
        /// <param name="user">string: Username.</param>
        /// <param name="plainpass">string: Plain text password.</param>
        /// <returns>iCampaign.TACS.Client.Credentials: object.</returns>
        public Credentials Login(string project, string user, string plainpass)
        {
            //  Initialize CurrentCredentials property
            _CurrentCredentials = null;

            // Encrypt the password
            string hashedPass = "";
            if (plainpass.Length != 0)
                hashedPass = Security.CreateHash(plainpass);

            //  Use SOAP proxy to TACS.NET AccessService
            AccessServiceProxy.AccessService accessService = new 
                iCampaign.TACS.AccessServiceProxy.AccessService();
            //  Consume the web service and process authentication request
            try
            {
                _CurrentCredentials = accessService.Login(project, user, hashedPass, this.ApplicationToken);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return this.CurrentCredentials;
        }
Пример #26
0
 internal string DeleteProject(string project, string role, Credentials credentials)
 {
     throw new System.NotImplementedException();
 }