It depends on a tense:
1) Past Simple
I bought a car. -- I didn't buy a car.
I had a car some time ago. -- I didn't have a car some time ago.
Passive
A car was bought by me. -- A car wasn't bought by me.
2) Past Perfect Tense
Before I passed to a college I had already bought a car. -- Before I passed to a college I hadn't already bought a car.
Before I passed to a college I had already had a car. -- Before I passed to a college I hadn't already had a car.
Passive
A car had been bought by me before... -- A car hadn't been bought by me before...
So, the difference between *hadn't* and *didn't* is that they are used in different Tensestenses and have different meaning. IIn this case the sentence
Please do not dock my pay as I was in the office but hadn't brought my ID card.
is a correct Past Perfect sentence.