If the individual accepts an ideology which is represented by the person in charge, then the individual's actions are legitimate. To test that hypothesis, Milgram actually conducted the experiments again in a set of run-down offices with no association with the prestigious Yale University. But to criticise Milgram's experiments as artificial on those grounds is to miss the fundamental point that the subjects were involved in real life. Scientific experiments are part of the world we live in. It is precisely our modern ideology of science that legitimated the subjects' actions.
Science is modern, progressive, objective, dispassionate, prestigious.
It was those values which attach to science and the scientist that made the subjects behaviour acceptable to them. Swap that ideology for the ideology of the German master race and you have unquestioning obedience to Nazism. Such obedience would not need to be based in any sense on brutal power relationships, but would rest on the voluntary surrender of the individual's independent moral judgement. That would be subordinated to the central value system of the larger social organization. One doesn't need to look so far afield as Nazi Germany, either.