How to convert 4 bytes into a long?

I do get interesting results and am still looking for a solution. It looks like the shift operator is only 16 bit. The cast to a long swaps nibbles on some of the bytes, which is strange. Thanks everyone for your help so far.

byte d[4];
long adc_value;

d[0]=0x87;
d[1]=0x65;
d[2]=0x43;
d[3]=0x21;

adc_value=0;
adc_value += d[0] << 24;
adc_value += d[1] << 16;
adc_value += d[2] << 8;
adc_value += d[3];
Serial.println(adc_value,HEX); //--> prints 4321 (expected 87654321)

adc_value = *((long *)d);
Serial.println(adc_value,HEX); // --> prints 21346587 (expected 21436587)

d[0]=0x12;
d[1]=0x34;
d[2]=0x56;
d[3]=0x78;

adc_value=0;
adc_value += d[0] << 24;
adc_value += d[1] << 16;
adc_value += d[2] << 8;
adc_value += d[3];
Serial.println(adc_value,HEX); //--> prints 5678 (expected 12345678)

adc_value = *((long *)d);
Serial.println(adc_value,HEX); // --> prints 78563412 (expected 87654321)