Monday, June 10, 2019

How to grant a local user the access to restart a service

Hi Guys,
Been sometime. Have been working for a project for a close friend of mine. (Yea I am doing some consulting finally). And there have been a plethora of things I did for the project which I wanted to blog on but then time is always against us.

I found this topic interesting and challenging and the work done (after a lot of reading and understanding) was pretty simple. So mentioning the same in today's blog.


We are going to change the permission of a user(local user) to restart a service in a non-domain controlled server. i.e. not connected to an Active directory.

By default a local user will not have permissions to restart a service. If a user goes to the services console(services.msc) he/she will see the start and stop functions to a service being grayed out.
Now to grant him the permissions we can use a lot of ways which is described quite well in the blog 

I did not want to use any third party software and complete the activity using simple pwershell commands. I am assuming the service name to be "Somefoobarservice" and the local user to be "tushar" (just for the name sake).

We need to open an powershell window as an admin. (just right click on the powershell and click on run as admin). Once you have the powershell opened use the command "sc.exe" . This utility is used to communicate with Service Control Manager and Services. You can just type sc.exe to give a help on the utility.


We need to first understand which user has what permissions on the service. We will use the sdshow option for sc.exe utility which will display the service security options.

example : sc.exe sdshow "Somefoobarservice"

you will get an output like the below

D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)

Now it may seem a lot gibberish but it will make sense once we discuss the output.

The first letter in the beginning of the output
S: — System Access Control List (SACL)
D: — Discretionary ACL (DACL)

The first letter after brackets means: allow (A) or deny (D).

The next set of symbols is assignable rights.

CC — SERVICE_QUERY_CONFIG (request service settings)
LC — SERVICE_QUERY_STATUS (service status polling)
SW — SERVICE_ENUMERATE_DEPENDENTS
LO — SERVICE_INTERROGATE
CR — SERVICE_USER_DEFINED_CONTROL
RC — READ_CONTROL
RP — SERVICE_START
WP — SERVICE_STOP
DT — SERVICE_PAUSE_CONTINUE


The last 2 characters are objects (user group or SID) that are granted permissions. There is a list of predefined groups.


AU Authenticated Users
AO Account operators
RU Alias to allow previous Windows 2000
AN Anonymous logon
AU Authenticated users
BA Built-in administrators
BG Built-in guests
BO Backup operators
BU Built-in users
CA Certificate server administrators
CG Creator group
CO Creator owner
DA Domain administrators
DC Domain computers
DD Domain controllers
DG Domain guests
DU Domain users
EA Enterprise administrators
ED Enterprise domain controllers
WD Everyone
PA Group Policy administrators
IU Interactively logged-on user
LA Local administrator
LG Local guest
LS Local service account
SY Local system
NU Network logon user
NO Network configuration operators
NS Network service account
PO Printer operators
PS Personal self
PU Power users
RS RAS servers group
RD Terminal server users
RE Replicator
RC Restricted code
SA Schema administrators
SO Server operators
SU Service logon user

Now I hope the gibberish statement makes much sense. Now is the task to identify the user SID. This is the unique id for which the user has to be granted permissions. Now we can do it a lot of ways. I am trying to pen down the easiest. 
You just type the below command using WMIC ( Windows Management Interface Command).
 wmic useraccount get name,sid
This will list the users and the SID for all the users. you need to copy the SID of the user you want to grant permission to the service. 
Guest           S-1-5-21-2719496566-3729557865-1934094733-501
tushar        S-1-5-21-2719496566-3729557865-1934094733-1011
Something like the above. Now we use the SID of tushar and then update the service "Somefoobarservice" using the utility sc.exe again. This time we will use the utility sdset which sets a service's security descriptor.
Before that we will have to prepare the new security descriptor for the service. Here we will append the new descriptor of the service for tushar to the orignal one( this will help retain the previous user permissions on the service). 

The original descriptor
D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)
The new descriptor for tushar. Here we are granting permissions to read the service, start, stop, restart and pause the service. 
(A;;CCLCSWLOCRRCRPWTDT;;;S-1-5-21-2719496566-3729557865-1934094733-1011)
So the new descriptor is (augmenting the new one for tushar to the orignal one, ensure there is no space) 
D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;CCLCSWLOCRRCRPWTDT;;;S-1-5-21-2719496566-3729557865-1934094733-1011)

Now time to update the service(remember the powershell should be running as admin)
sc.exe sdset "Somefoobarservice"  "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;CCLCSWLOCRRCRPWTDT;;;S-1-5-21-2719496566-3729557865-1934094733-1011)"
Once done you will get a message like "[SC] SetServiceObjectSecurity SUCCESS".
Viola !!! Now the local user has permissions to start, stop, restart and pause the service like an admin. This is one of the ways you can have controlled permissions for a user on a particular service rather than granting him admin permissions on the server. 


Thanks,
Tushar 
























Tuesday, January 1, 2019

New Year 2019

Hi Guys,
It has been some time I have stopped working on my blogs and since the time I did I missed out on something I was passionate about and stopped growing technically. I believe sharing makes you grow more than keeping things to yourself. I promise I will blog more and share more this year.

There are a lot of things I am working on in parallel but not limited to cloudera, sql and aws. I will try to share my experience as much as I can.


Thanks,
Tushar Kanti

Monday, December 25, 2017

The iDream

Since 2008 Apple announced the amazing range of products be it iPod Touch or iPhone or Macbook. I always wanted to lay my hands on one of those. There were times I was envious of the people owning them as they returned from onsite(oh let's not go into the details of meritocracy for the same). I finally decided to have one. The Macbook air can still be explained as because of the  products they have for creativity which is some how shunned in windows but most importantly the feel of having a Macbook is far more awesome.
Also got a iPhone to add flavor to the fun and trust me it is much more hyped that for real. Sure the form factor and the mental satisfaction you have is unparalleled but other than that it is just a phone. When we have so many good build phones coming in less than half of the price value it is definitely a major waste of money. But yes after using it for a couple of months given a chance I will not be willing to go back to Android and Hell Never to Windows phones. But most the credit to this shift of phone is to Nokia for not doing, what was required in time. 


Thanks,
Tushar 

To configure the local loop back adapter in vmware

To install the Loopback adapter:

Click Start > Control Panel > Add Hardware.
Click Next on the introduction dialog box.
Select Yes, I have already connected the hardware and click Next.
Select Add a new hardware device, and click Next.
Select Install the hardware that I manually select from a list (Advanced), and click Next.
Select Network adapters, and click Next.
Select Microsoft as the manufacturer, select Microsoft Loopback Adapter as the adapter, and click Next.
Click Next to confirm the installation.
Click Finish to complete the installation.

To configure the newly created adapter:

Click Start > Control Panel > Network Connections.
Select the newly created connection (named Local Area Connection #, where # is its order number).
Right-click on the selected connection and choose Properties from the menu.
Confirm that Microsoft Loopback Adapter or Microsoft Loopback Adapter # is displayed in the Connect Using: field. If it is not, return to step 2 and retry properties for another adapter.
Deselect everything except Internet Protocol (TCP/IP).
Select Internet Protocol (TCP/IP), and click Properties to open Internet Protocol (TCP/IP) Properties.
Select Use the following IP address:. Fill in the IP address: and Subnet mask: fields. For example, 10.10.10.10, 255.255.255.0.
Click Advanced to open Advanced TCP/IP Settings.
Switch to WINS and select Disable NetBIOS over TCP/IP.
Click OK to close Advanced TCP/IP Settings.
Click OK to close the Internet Protocol (TCP/IP) Properties.
In Windows XP only, Deselect Notify me when this connection has limited or no connectivity to remove the connection warning icon from the system notification area.
Click OK to close the connection properties.

Slowness Syndrome

Have you ever felt the need to fuel the jet??  Do you know what it feels like to drive at 40kmph when you have witnessed 180kmph? That should give you a taste of what it feels like when you need to brake and slow down in pressure of society. Well this is what one can feel a lot of times. People here don't wana walk they just wana stroll and trust me when you wana run they will pull you back. Be it back bitching be it hideous politics oh yes sir they are bound to these abilities you won't find any where. Why can't people go fast and ahead and why can't they let go of their laid back attitude. People who should have been friendly and homely have grown wild and try to make people uneasy and unhappy and it's a shame they find happiness in that. I feel a lot suffocated but have to put on a visage so that all feel I am gelled in. 

Thursday, July 23, 2015

Loosing track of time

There was a time when we used to see dates on calendar and remembered what was the special occasion of the day. Today we see the date in our phone , laptop , desktop, tablet everyday every moment.. Yet we don't remember the special dates unless we get n update of Facebook or a whatsapp update.. Loosing track of the important has not been new but used to happened when we hit 80s.. But now we have become so prone to technology we hardly let our brain think on the things which should be more important to us.. We r trying to compete everyday with the everyone trying to like more post more and update more trying to get cooler than others.. Recent dent being every second selfie.. So what's dere to detox from this?? Food fr thgt..

Tushar

Tuesday, February 24, 2015

Coratana Now Available in India for Nokia Lumia 1020

Hi ,
Finally Lumia Denim Update is available in India for Lumia 1020. There was a lot of buzz regarding the release date but no fine time line.

Even after the release when you try to activate Cortana you may get an error that the language and the region chosen are not correct.
I am still working on changing the language (presently 'English (India)')setting and region setting (presently 'India'). But does not seem to be working. Hopefully I will be able to fix it soon and will post the fix as well. Till then will have to google a couple of more blogs.

Got some update for the language settings.. It's funny cause we have to use English (UK) for India. :)

Below is mentioned the chart the region, language and speech settings.. Hope it helps..


Ref :
http://answers.microsoft.com/en-us/winphone/forum/wp8-wpcortana/when-where-and-on-what-phones-is-cortana-available/1b94c48b-20a4-483f-8aee-3fde582aecd4

Cheers!!!!