You need your d number to open a bank account, to rent a place to live and to pay your taxes.
When you get a d number depends on your situation.
You may then apply for a national identity number and use that instead of your d number.
If you should have been registered as resident in Norway and received a birth number instead of a d-number, you can send a residence registration form and documentation confirming your stay in Norway to the The Norwegian Tax Administration (external website).
A DUF number is not the same as a d number. The DUF number is your registration number in the computer system of the Norwegian Directorate of Immigration.