the class TopologyManager is for SharePoint Server 2003. So the code is outdated for MOSS 2007.
just to make the point, when you try to look for a property
say :
anyControl.Text = userProfile["Company"].ToString();
you must first check if that property exist
you could not rely on : userProfile["Company"] != null
you must check also userProfile["Company"].Value != null