This sentence is a bit irregular although most native speakers, myself included, wouldn’t notice it unless someone specifically asks about it. What’s irregular is that が makes us parse it this way.
みんなが寄ってくるので、[教授がハリーをひとり占め]にはできなかった。
Syntactically, this is identical to this.
みんなが寄ってくるので、[ひとり占め]にはできなかった。
Usually, if you want to specify who does the monopolization and who they monopolize, you would make a sentence and turn it into a noun phrase, like this.
みんなが寄ってくるので、[教授がハリーをひとり占めにすること]はできなかった。
I would say the original sentence is a somewhat “sloppy” version of this sentence. They mean the same thing.
〜を独り占めする and 〜を独り占めにする are practically interchangeable. In fact, the following sentences both sound completely natural.
みんなが寄ってくるので、[ひとり占め]はできなかった。
みんなが寄ってくるので、[教授がハリーをひとり占めすること]はできなかった。
However, removing に from the original sentence makes it a bit weirder.
? みんなが寄ってくるので、[教授がハリーをひとり占め]はできなかった。
教授が and ハリーを, which are expected to modify some verb, seem more out of place in the noun phrase in the brackets. I suppose に reminds us of the existence of an omitted verb, namely する in the more complete version with a nominalized sentence, and that makes the original sentence easier to understand the way it is intended despite its “sloppiness.”
は singles out what the professor couldn't do among all things. I get a sense of “even if they wanted to” from it.
Lastly, 教授はハリーがひとり占めできなかった would mean a completely different thing. Harry would be the one monopolizing the professor.