HTTP Client From Network Share

reuvygroovy 776 Reputation points
2022-02-13T16:42:45.857+00:00

We have the following code
using System;
using System.Net.Http;
using System.Threading.Tasks;

namespace Console99
{
    internal class Program
    {
        public Program()
        {
        }

        private static void Main(string[] args)
        {
            try
            {
                using (HttpClient client = new HttpClient(new HttpClientHandler()
                {
                    UseDefaultCredentials = true
                }))
                {
                    var result = client.GetAsync("https://server/WS/api/UsersApi?id=012314");
                    var a = result.Result.StatusCode;
                    Console.Write("hello: " + a);
                }

            }
            catch (Exception exception)
            {
                Console.Write(exception.StackTrace);
            }
            Console.ReadKey();
        }
    }

When the code runs from a user with Local Admin permissions, it works OK. When a 'limited' user runs the code, it fails. What is strange though is after a local admin has ran the code, the regular user now may run the code. It seems like this first admin-run does something to allow the following users to run it.

Any idea what this could be?

I should note, this happens when we run an app from a network share. when the same user runs the same code from his local PC it works fine.

Windows Network
Windows Network
Windows: A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.Network: A group of devices that communicate either wirelessly or via a physical connection.
735 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,586 Reputation points
    2022-02-18T14:28:05.203+00:00

    Hello @reuvygroovy

    This is obviously related to NTFS permissions over the location of the script. Once used the admin, it caches the "Execute" permission and then the user has access since probably you already gave the user Read/Write on the location.

    To verify this, try to enable "Full Control" to the standard user over the script file in the network location.

    Hope this helps with your query,

    ------
    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.