My app is running on client's network, where they have a windows forest with multiple Domains and Workgroups. We're using NetServerEnum function, with the flag SV_TYPE_DOMAIN_ENUM, for enumerating all of these "sub-networks" - domains and workgroups.
After that, we need to determine for each name whether it's a WORKGROUP or a DOMAIN.
One option I had is using DsGetDcName, knowing it should fail for a workgroup, but I'm quite sure there are better ways.