0

Windows service throwing error ACCESS DENIED While trying to access website that uses windows authentication. While deploying this service its using NT-Authority as windows credential

WebClient wc = new WebClient();
string page = wc.DownloadString("https://abcxyz.com/");
Vipul Handa
  • 109
  • 1
  • 10
  • 1
    I think this is an _[XY Problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem)_, try to specify what are you trying to do rather that just exploring the issue with your current approach – jalsh Feb 10 '20 at 03:42
  • Unable to get user/pwd from active directory . – Vipul Handa Feb 10 '20 at 03:42
  • 1
    "Help me install my malware as services without asking for permissions" type of questions rarely fare well on SO. Some starting points so you can [edit] post to demonstrate your research - AD does not store passwords... Unconstrained elevation of privileges (especially to admin/system level accounts) is not something you can do in any system... – Alexei Levenkov Feb 10 '20 at 03:43
  • You have to grant the identity of this Windows service the permissions to access external services (and maybe also configure a valid proxy for it if by default it cannot connect externally). Typical system session (session 0) issue so you can find tons of similar posts. – Lex Li Feb 10 '20 at 03:57
  • Although when i use wc.UseDefaultCredentials = true; its working on local debugging session – Vipul Handa Feb 10 '20 at 04:04
  • You just need to set the [`Credentials`](https://learn.microsoft.com/en-us/dotnet/api/system.net.webclient.credentials?view=netframework-4.8) property with the credentials you want to use. See [this answer](https://stackoverflow.com/a/1883697/1202807). – Gabriel Luci Feb 10 '20 at 19:08
  • When i am debugging service its taking my user credentials but on deploying service it is getting username as NT_Authority – Vipul Handa Feb 13 '20 at 14:06

0 Answers0