コード例 #1
0
        public List <Models.Permissions> GetAllDatabasePermissions(string DomainOrServerName, string UserName, string Password, int DatabaseID, bool domain = true)

        {
            List <Models.Permissions> permissions = new List <Models.Permissions>();

            try
            {
                var logic = new Square9.SecurityDisplay.Logic.UsersLogic();
                permissions = logic.GetAllDatabasePermissions(DomainOrServerName, UserName, Password, DatabaseID, domain);
            }
            catch (Exception)
            {
                throw;
            }

            return(permissions);
        }
コード例 #2
0
        public HttpResponseMessage GetAllDatabasePermissions(int DatabaseID, bool isDomain = true)
        {
            List <Models.Permissions> permissions = new List <Models.Permissions>();
            IEnumerable <string>      headerValues;
            var authHeader = string.Empty;

            if (Request.Headers.TryGetValues("Authorization", out headerValues))
            {
                authHeader = headerValues.FirstOrDefault();
            }

            try
            {
                var logic    = new Square9.SecurityDisplay.Logic.UsersLogic();
                var authData = logic.GetAuthValues(authHeader);
                permissions = logic.GetAllDatabasePermissions(authData.Domain, authData.Username, authData.Password, DatabaseID, isDomain);
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.Forbidden, "Unable to return permissions: " + ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, permissions));
        }