Tuesday, June 15, 2021

Shayad Chords

Shayad is a very special song from the Movie Luv Aaj Kal 2(the movie should have been christened as Luv Aaj Kal 0.5  😈 )

Sung by Arijit where he also plays the Acoustic Guitar. Music by Pritam 


[Chords]: Em , Am , D , G , Bm , C

 [Intro]

C               D               G

Shayad kabhi na keh sakoon main tumko

Am        D             Em

Kahe bina samajh lo tum shayad

C           D               G

Shayad mere khayal mein tum ik din

Am         D             Em

Milo mujhe kahin pe ghum shaayad

          G                 C

Jo tum na ho... rahenge hum nahin

          Em            D

Jo tum na ho... rahenge hum nahin

  Bm            C                   G

Na chahiye kuch tum se zyada tum se kam nahin

          Em                D

Jo tum na ho... toh hum bhi hum nahi

          C                 D

Jo tum na ho... toh hum bhi hum nahi

  Bm            C                   G

Na chahiye kuch tum se zyada tum se kam nahin

 

 

[Verse 1]

Bm

Aankhon ko khaab dena

C

Khud hi sawaal karke

G                   D

Khud hi jawaab dena teri taraf se

Bm

Bin kaam kaam karna

C

Jaana kahin ho chaahe

G                   D

Har baar hi guzarna teri taraf se

   G                    C

Ye koshishein toh hongi kam nahin

   Em                   D

Ye koshishein toh hongi kam nahin

  Bm            C                   G

Na chahiye kuch tum se zyada tum se kam nahin

          G                 C

Jo tum na ho... rahenge hum nahin

          Em            D

Jo tum na ho... rahenge hum nahin

  Bm            C                   G

Na chahiye kuch tum se zyada tum se kam nahin


The Full Song Lyrics:

 Shayad kabhi na kehe sakoon main tumko


Kahe bina samajh lo tum shayad

Shayad mere khayal mein tum ik din

Milo mujhe kahin pe ghum shayad


Jo tum na ho... rahenge hum nahin

Jo tum na ho... rahenge hum nahin

Na chahiye kuch tum se zyada tum se kam nahin


Jo tum na ho... toh hum bhi hum nahi

Jo tum na ho... toh hum bhi hum nahi

Na chahiye kuch tum se zyada tum se kam nahin


Aankhon ko khaab dena

Khud hi sawaal karke

Khud hi jawaab dena teri taraf se

Bin kaam kaam karna

Jaana kahin ho chaahe

Har baar hi guzarna teri taraf se


Ye koshishein toh hongi kam nahin

Ye koshishein toh hongi kam nahin

Na chahiye kuch tum se zyada tum se kam nahin


Jo tum na ho... rahenge hum nahin

Jo tum na ho... toh hum bhi hum nahin

Na chahiye kuch tum se zyada tum se kam nahin


Jo tum na ho...

Jo tum na ho...

Jo tum na ho...

Saturday, April 24, 2021

Scripting Domain Logins , Server Roles , Database User and User Permissions.

 Hi Guys,

Been so long I did post something. Well I really need to work on my clould blog as well but for today it will be just a simple blog on user security. 


I had to run through a lot of hoops so thought I will share the scripts with you. The requirement was to script out the Logins and the related users in the databases from one environment to other. 

So here goes the script. You need to replace the  [domain\windowslogin] with you DomainLogin for which you want to script out the permission. 

IF  (SELECT OBJECT_ID('msdb.dbo.storepermission') ) IS  NULL

begin

CREATE TABLE msdb.dbo.storepermission  (

ServerName sysname,

DBName sysname,

USerName sysname,

TypeOfLogin nVARCHAR(100),

PermissionLevel NVARCHAR(100),

TypeOfRole NVARCHAR(100)

)

END 

TRUNCATE TABLE msdb.dbo.storepermission


DECLARE @@login_name sysname ='domain\windowslogin'

--SELECT @@login_name

DECLARE @dbname VARCHAR(50)   

DECLARE @statement NVARCHAR(MAX)


DECLARE db_cursor CURSOR 

LOCAL FAST_FORWARD

FOR  

SELECT name

FROM master.sys.databases

WHERE 1=1

AND state_desc='online' 

OPEN db_cursor  

FETCH NEXT FROM db_cursor INTO @dbname  

WHILE @@FETCH_STATUS = 0  

BEGIN  

--SELECT @@login_name

SELECT @statement = 'use '+@dbname +';'+ 'insert into msdb.dbo.storepermission(ServerName,DBName,USerName,TypeOfLogin,PermissionLevel,TypeOfRole)SELECT


 ServerName=@@servername, dbname=db_name(db_id()),p.name as UserName, p.type_desc as TypeOfLogin, pp.name as PermissionLevel, pp.type_desc as TypeOfRole 


FROM sys.database_role_members roles


JOIN sys.database_principals p ON roles.member_principal_id = p.principal_id


JOIN sys.database_principals pp ON roles.role_principal_id = pp.principal_id

where p.name=''domain\windowslogin''' -- Change the user name


EXEC sp_executesql @statement

PRINT @statement


FETCH NEXT FROM db_cursor INTO @dbname  

END  

CLOSE db_cursor  

DEALLOCATE db_cursor





 SELECT 'IF NOT EXISTS(SELECT principal_id FROM sys.server_principals WHERE name = ''domain\windowslogin'') BEGIN CREATE LOGIN [domain\windowslogin] FROM WINDOWS  END; '

 

SELECT

--R.name AS server_role

-- , P.name AS role_member ,

'EXEC master..sp_addsrvrolemember N' + '''' + P.name + '''' + ', N' + '''' + R.name + '''' + ';' AS command

FROM sys.server_role_members RM 

INNER JOIN sys.server_principals P ON RM.member_principal_id = P.principal_id

INNER JOIN (SELECT principal_id, name FROM sys.server_principals WHERE type_desc = 'SERVER_ROLE') R

ON RM.role_principal_id = R.principal_id

WHERE P.name NOT LIKE '#%'

AND P.name NOT LIKE 'NT %'

AND P.type_desc <> 'SERVER_ROLE'

AND P.name NOT IN ('sa')

AND P.name='domain\windowslogin'

ORDER BY R.[name], P.[name]


SELECT 'use '+DBName+' IF NOT EXISTS(SELECT principal_id FROM sys.database_principals WHERE name = '''+USerName+' '') BEGIN CREATE USER ['

+USerName+'] FOR LOGIN ['+ USerName+'] END ; EXEC sp_addrolemember N'''+PermissionLevel+''', N'''+USerName+''';'

 FROM msdb.dbo.storepermission


Hope this helps you. 


Thanks,

Tushar

Wednesday, February 24, 2021

Updating the Domain Credentials from Remote Desktop System

 Hi,

I have had so many opportunities when I had to change my passwords but I did not remember how to get the change password console in the remote system.

So without further adieu let me give you the shortcut to the password change console.

This works with Windows Server 2016 so I assume it will work with most of the newer versions.


The shortcut is [cntrl] + [alt] + [end]


So you will be able to see this console and then you just need to click on the Change a password option and the change password console will open up. 

Hope this helps you next time when you want to reset a password for your domain logon from a remote desktop system.


Thanks,

Tushar Kanti


Thursday, February 11, 2021

Getting Lazy is Getting Comfortable or Getting Old

 Hey,

Been a month already into new year and I have not put in anything in my favourite blog. You know what I think after sometime we start to find happiness everywhere and that is where we start getting mature and start behaving matured. One we understand that we need to get money to pay bills and two we know where to get easy money(keeping a day job) and where to get real money aka investment in real estate, travel blogging, basically following your passion not limited to your study or bathroom :)


So we all have developed some basic skills (IT Support is not a skill we develop it's like we were enslaved into it), like Technology, Music, Art; and it is good enough to pay for our real bills but we have put in so much of planning small things that we are losing the larger picture. 

Or may be just me.. lol.. 

So you wana get up early and strech out and then you see the guitar giving you the sad stare and then when you start tuning the guitar to play you start to think that the code you left running in production last night might have completed and you will need to enable the job which you disabled to check the issues in the data consistancy. And trust me by the time you login to the VPN to connect you realize your phone is out of juice and just when you plug in the charger you realise that the socket is still broken which you had to fix but then you forgot to get the screw driver which was broken.. and on and on... and suddenly you realise your kid is up. 


You get it right that we have been amazingly undisciplined in our life so when we try to work on something i.e. we want to take a step ahead in our life with anyone of our so called passions we need to take atleast a couple to steps back and then revise things and then take a step forward. This has been a gift of the habbit of fast food generation that we are. We need things super fast but we do not realise that patience is one thing that we need to have in anything that we want to achieve. 


So I think we need to slice our life (hey not literally just a time slice will do)  and then use those slices to make most of it. We need to make sure that every slice is fun and we need to have more of it. 


So initially it will all be boring and slow and may be it will not make sense but I think it will work out pretty well soon. I used to play the guitar and I still am there but now I do not play to go somewhere I just play to play and to enjoy what I can do with it. Singing is something I have lost the touch but I miss that the most. I mean so many things to do in just one life. 


Of all the things that I have lost I miss my time the most. But it's just been 10 years that I been like this and I think I will turn around, stronger than before. 


Tushar





Wednesday, September 2, 2020

How IT is fixing the mistakes and evolving

HI, 

So what did change in the world of IT for the past 2 decades? Well literally everything right from the keyboard and mouse (became wireless) to monitors became flatter and thinner and brighter. But today wanted to bring something more basic to discuss. You know we all keep talking about AI and Machine Learning if you back just a decade and relook the comments on posts of those articles you will see most of the industry would have commented that is still in it's inception and it will take forever and next generation will be able to harness the benefits. Guess what AI and Machine learning are here and they are defining how we are working towards achieving our daily and annual goals. 


So the industry roughly had the IT boom like 2 decades ago when companies like Apple and Microsoft started making hardware and software for people like us. Now all was good people started to accept new technologies and all started to get IT Aware but somewhere mid stream people started to tame the RockStars of the IT as slaves and people with absolutely no skills and information started to drive the IT Industry and this led to the whole chaos which we live in today. And if you watch closely all the major flaws and mistakes came in picture only when the mass hiring of engineers started to happen(I am no exception to that process but I gladly accept that). Now imagine someone having absolutely no clue in Operating System having a Mechanical Degree in Engineering designing a WebPage for an online e-commerce portal. Image how buggy that system designed will be some of us will argue that they have had great mentors and great books and blogs to refer. But imagine the mistakes they did and got passed on to their subordinates and juniors like the ripple or the domino effect. We are living with those mistakes in everything in IT, you can pick anything even as basic as Nomenclature to as big as Network configuration. All is messed up and you know the biggest contribution to this chaos is from the companies who boast to Marvel in the field of IT. And you cannot even get started about how much I love the BSc and Commerce graduates coming into IT. 


Well this would have never ended and we would have just cursed the hardware ( I mean you also have mechanical engineers designing MicroProcessors chips but let's just say that is really a handful and they ended up there because of their shear passion and dedication and not some mass recruitment). I mean there is no end to how much you can scale up (both horizontally and vertically) as long as you can drain some more money from the poor client who believes the IT companies know more than them about Computers. May be once in a year we should look at some of the specs of the Rovers that went across planets to gather data. I mean if you look at the hardware they had and the software written we should feel not only ashamed but guilty of how much we need to know even before we start writing the first "Hello, World!" program. 

Somewhere down the line came up with a brilliant Idea of having setup Infrastructure in Cloud and this can be the start of correcting the mistakes we did in our Infrastructure and I believe it will take some time to get the morons out of the Industry who are only surviving because they can point out mistakes in someone's work or share a warm mug of coffee with someone important. 

Now we have infrastructure as an Application you can built a failover over cluster with click of buttons and the amazing part is you will be getting the almost best thing possible. I know it takes away customisation out of the picture but given what we are dealing as of now that can be really helpful. So what about the software well that is changing too and we have web based workflow applications which can stitch our work together to fetch the data do the ETL and create reports. This is shaping up really fast and we cannot keep up with all the providers coming out with new tools and designs literally everyday. 

We can create a service without thinking about the server core and memory. You can create the service and just change the tier when you hit a bottle neck. The only downside is the cost which I think is wise keeping your own infra which gets obsolete every 5years. 

What we will witness and MARK MY WORDS WE WILL. The next decade will be the evolution of people working in IT. To begin with the Ways of Working will change. No one will be required to work from Office unless you want to. People will be working from the place they like and will have a device which they like to work on. You will see the desktops replaced by mobile tablets and meetings getting boring as the audience will change. Yes people will start working with smaller entities which reflect more of their personal nature rather than having to work monotonically in IT Giants. Kids are learning coding today to create applications so when they hit the IT industry a decade later we will have but no room for people who think just sitting around quietly having a warm mug of coffee will keep their jobs safe. Or someone who has a habit of rubbing nose into everyones work with no contribution whatsoever will have to sadly go home and find something more useful to do with their lives. People will start to speak for themselves in IT which is taken care of by just a bunch of people who take the accolades and demean the hardworking people. 

You will stop saying the jargon YOU NEED TO BE A SMART WORKER. I mean literally the only people speaking these words in IT Giants are the dumbest people I have witnessed in my life. 

We will always have C Perl Python Ruby Java in some form or another. You will need to know the basis of the working of a Hardware and Software before you start working on anything and Kids are learning that now and when they hit the Industry and trust me the only ones entering will be the ones who will be the RockStars only to kick some ass. They will take no BS whatsoever and will only work if they think they will have something to contribute. I mean people will need to make money to keep paying bills but now we all know earning money does not mean working for 8 hours and definitely not in something we do not like to. 

Change is the only thing Permanent


Thanks,

Tushar 


   

Wednesday, February 12, 2020

MagicMouse2 in Windows 10

Well I had been looking forward to getting my hands on Microsoft Surface Arc Mouse for a real long time. But when the time came I had to rethink. In fact I ordered the same and returned the package as it was the Version 1 released sometime in 2016. So when I got a chance to reorder the same I did an overall study and comparison between Surface Arc Mouse and Apple Magic Mouse 2. I chose the later one. There are a quite a bit of things that stand out for Apple Magic Mouse 2 and it's my personal opinion.

Enough of history. Now for the real reason of this blog is to keep or help Windows 10 users get the driver for Apple Magic Mouse 2 so that they can work with Scroll functionality of the mouse. I had to do some study for whole day and then realised there are a couple of ways we can do it. I chose the paid one as well but then it struck me I do not want to pay for some driver and run some third party tool on my Windows just to make a mouse function properly. I hunted down the driver (well it was a couple of hours of googling and downloading). I have put it on a public folder and anyone can download and use it.

So here is the direct link to the ftp location for MagicMouse2 driver for Windows10.

Cheers!!!!

Tushar Kanti


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