Invoke CLR assembly in SQL Server with administrator privileges?

58 Views Asked by At

Interprocess communication based on pipe scheme is performed in the CLR assembly code as follows:

    static void SendMessage(Process process, string message)
    {
        try
        {
            using (NamedPipeClientStream pipeClient = new NamedPipeClientStream(".", "PipeName", PipeDirection.Out))
            {
                pipeClient.Connect();

                using (StreamWriter sw = new StreamWriter(pipeClient, Encoding.UTF8))
                {
                    sw.Write(message);
                }

                Console.WriteLine("Message sent to target process.");
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    }

Run to pipeClient.Connect(), prompting:

no permission to access the resource exception:System.UnauthorizedAccessException

But when I run the above code as an exe, it's fine. I guess this has something to do with the permissions associated with the SQL Server login user, but I don't know how to set it.

I want to know how to set up SQL Server's login user so that it can run CLR assemblies based on system administrator privileges. (It is now possible to successfully call the CLR assembly using SQL, but when accessing some system resources, such as pipe, the permission is insufficient).

0

There are 0 best solutions below