Getting Domain Name 
Author Message
 Getting Domain Name

Does anyone know how to get the domain name in Visual C++.  I tried the
GetDCName function but it didn't seem to return to me the domain name.
Could some one offer any examples would be greatly appreciated.

Robert A. Thompson



Sun, 09 Jul 2000 03:00:00 GMT  
 Getting Domain Name

Quote:

>Does anyone know how to get the domain name in visual C++.  I tried the
>GetDCName function but it didn't seem to return to me the domain name.
>Could some one offer any examples would be greatly appreciated.

>Robert A. Thompson

Robert:

Check out the MS KB articles.  They have an example for NT.



Wed, 19 Jul 2000 03:00:00 GMT  
 Getting Domain Name

I believe GetDCName returns the name of the Domain controller (Primary?)
which is the main server on your network.  There must be a API for the
domain name, but I haven't found it - if anyone knows .... please tell.

Kev.



Quote:
> Does anyone know how to get the domain name in visual C++.  I tried the
> GetDCName function but it didn't seem to return to me the domain name.
> Could some one offer any examples would be greatly appreciated.

> Robert A. Thompson



Sat, 22 Jul 2000 03:00:00 GMT  
 Getting Domain Name

Try the NetWkstaGetInfo() API.

--
Paul Little, Software Engineer



Quote:
> I believe GetDCName returns the name of the Domain controller (Primary?)
> which is the main server on your network.  There must be a API for the
> domain name, but I haven't found it - if anyone knows .... please tell.

> Kev.



> > Does anyone know how to get the domain name in visual C++.  I tried the
> > GetDCName function but it didn't seem to return to me the domain name.
> > Could some one offer any examples would be greatly appreciated.

> > Robert A. Thompson



Sun, 23 Jul 2000 03:00:00 GMT  
 Getting Domain Name

You can use the WNetEnumResource

like this:

Private Const NO_ERROR = 0 '  dderror
Private Const ERROR_NOT_CONTAINER = 1207&
Private Const ERROR_INVALID_PARAMETER = 87 '  dderror
Private Const ERROR_EXTENDED_ERROR = 1208&
Private Const ERROR_NO_MORE_ITEMS = 259&
Private Const ERROR_MORE_DATA = 234&  ' Made by PMN instead of
ERROR_NO_MORE_ITEMS
Private Const ERROR_NO_NETWORK = 1222&
Private Const ERROR_INVALID_ADDRESS = 487&
Private Const ERROR_BAD_PROVIDER = 1204&
Private Const ERROR_UNKNOWN = 10000&

Private Type NETRESOURCE
    dwScope As Long
    dwType As Long
    dwDisplayType As Long
    dwUsage As Long
    lpLocalName As Long
    lpRemoteName As Long
    lpComment As Long
    lpProvider As Long
End Type

Declare Function WNetOpenEnum Lib "mpr" Alias "WNetOpenEnumA" _
                 (ByVal dwScope As Long, ByVal dwType As Long, ByVal dwUsage
As Long, _
                 LPNETRESOURCE As Any, lphEnum As Long) As Long

Declare Function WNetEnumResource Lib "MPR.DLL" Alias "WNetEnumResourceA" _
                 (ByVal hEnum As Long, lpcCount As Long, lpBuffer As Any, _
                 lpBufferSize As Long) As Long

Declare Function WNetCloseEnum Lib "MPR.DLL" _
                 (ByVal hEnum As Long) As Long

   __o                                         Peter Meldgaard Nielsen
  -\<,                                   <http://home4.inet.tele.dk/pmn/>

Quote:

>Does anyone know how to get the domain name in visual C++.  I tried the
>GetDCName function but it didn't seem to return to me the domain name.
>Could some one offer any examples would be greatly appreciated.

>Robert A. Thompson



Sun, 23 Jul 2000 03:00:00 GMT  
 Getting Domain Name

Actually you need to use NetWkstaUserGetInfo (in NETAPI32.DLL).
NT only.

On Win95, you need totally different code.
Alas, there's 16-bit APIs but you usually want this info in a 32-bit program.
MS' answer is to use the thunk compiler to make 32-bit code that can call the
appropriate 16-bit APIs.
I never needed it that bad (yet) to bother.

    - Howard

Quote:

> Try the NetWkstaGetInfo() API.

> --
> Paul Little, Software Engineer



> > I believe GetDCName returns the name of the Domain controller (Primary?)
> > which is the main server on your network.  There must be a API for the
> > domain name, but I haven't found it - if anyone knows .... please tell.

> > Kev.



> > > Does anyone know how to get the domain name in visual C++.  I tried the
> > > GetDCName function but it didn't seem to return to me the domain name.
> > > Could some one offer any examples would be greatly appreciated.

> > > Robert A. Thompson

--
----------------------------------------------------------------------

----------------------------------------------------------------------
Never confuse motion for action. -- Benjamin Franklin
----------------------------------------------------------------------
In the Information Age, the first step to sanity is FILTERING.
Filter the information; extract the knowledge.
                   -Zetetic Commentaries, Kira Evans
----------------------------------------------------------------------


Wed, 26 Jul 2000 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Getting domain name of parent domain

2. Getting Domain name

3. Getting Domain Name

4. API for getting domain names from VB6

5. Getting name from Domain Name Server in VB?

6. Getting the Domain Name

7. Getting user names on NT domain

8. Getting user names of the same domain.

9. Getting the NETBIOS name of a DNS-style domain

10. Getting Network Domain name.

11. Getting Domain Controller Name

12. Getting The Full Domain User Name In Win95

 

 
Powered by phpBB® Forum Software