A D number is a temporary identification number that you receive from the Norwegian Tax Administration when you need an ID number in Norway, but do not meet the criteria for being assigned a national identity number. You can read more about D numbers here.
A national identity number is an ID number for you with a right of residence or residence permit who are going to live in Norway for more than six months. You can read more about national identity numbers here.
If you have applied for protection (asylum) or for a residence permit in Norway, you will be assigned a DUF number. This is your registration number in the immigration administration's computer system, and it is not an ID number.