ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Get fully qualified domain name in vba (https://www.excelbanter.com/excel-programming/433305-get-fully-qualified-domain-name-vba.html)

rick

Get fully qualified domain name in vba
 
I have the api calls to get the username, servername and domainname but when
I call the NetWkstaUserGetInfo API specifying a level 1 information
structure into the following type declaration the wkui1_logon_domain only
returns the first characters.
For example, I get 'HQ' instead of 'HQ.ABCCO.COM'. Thanks for your help.
....rick

Private Type WKSTA_USER_INFO_1
'name of the user currently logged onto the workstation.
wkui1_username As Long
'domain name of the user account currently logged on
wkui1_logon_domain As Long
'list of other domains browsed by the workstation
wkui1_oth_domains As Long
'name of the authenticating server
wkui1_logon_server As Long
End Type
....
Dim typNTInfo As WKSTA_USER_INFO_1
'call the NetWkstaUserGetInfo API specifying a level 1 information structure
lngRet = apiWkStationUser(0&, 1&, lngPtr)
If lngRet = NERR_Success And lngPtr Then
Call sapiCopyMemory(typNTInfo, ByVal lngPtr, LenB(typNTInfo))
If Not IsNull(lngPtr) Then
With typNTInfo
glbUserName = fStringFromPtr(.wkui1_username)
glbDomainName = fStringFromPtr(.wkui1_logon_domain)
glbServerName = fStringFromPtr(.wkui1_logon_server)
glbOtherDomains = fStringFromPtr(.wkui1_oth_domains)
End With
End If
End If


Barb Reinhardt

Get fully qualified domain name in vba
 
Why have you declared everything as LONG?

"rick" wrote:

I have the api calls to get the username, servername and domainname but when
I call the NetWkstaUserGetInfo API specifying a level 1 information
structure into the following type declaration the wkui1_logon_domain only
returns the first characters.
For example, I get 'HQ' instead of 'HQ.ABCCO.COM'. Thanks for your help.
....rick

Private Type WKSTA_USER_INFO_1
'name of the user currently logged onto the workstation.
wkui1_username As Long
'domain name of the user account currently logged on
wkui1_logon_domain As Long
'list of other domains browsed by the workstation
wkui1_oth_domains As Long
'name of the authenticating server
wkui1_logon_server As Long
End Type
....
Dim typNTInfo As WKSTA_USER_INFO_1
'call the NetWkstaUserGetInfo API specifying a level 1 information structure
lngRet = apiWkStationUser(0&, 1&, lngPtr)
If lngRet = NERR_Success And lngPtr Then
Call sapiCopyMemory(typNTInfo, ByVal lngPtr, LenB(typNTInfo))
If Not IsNull(lngPtr) Then
With typNTInfo
glbUserName = fStringFromPtr(.wkui1_username)
glbDomainName = fStringFromPtr(.wkui1_logon_domain)
glbServerName = fStringFromPtr(.wkui1_logon_server)
glbOtherDomains = fStringFromPtr(.wkui1_oth_domains)
End With
End If
End If



rick

Get fully qualified domain name in vba
 
I believe all low-level API calls are DWORD thus the LONG.

"Barb Reinhardt" wrote in message
...
Why have you declared everything as LONG?

"rick" wrote:

I have the api calls to get the username, servername and domainname but
when
I call the NetWkstaUserGetInfo API specifying a level 1 information
structure into the following type declaration the wkui1_logon_domain only
returns the first characters.
For example, I get 'HQ' instead of 'HQ.ABCCO.COM'. Thanks for your help.
....rick

Private Type WKSTA_USER_INFO_1
'name of the user currently logged onto the workstation.
wkui1_username As Long
'domain name of the user account currently logged on
wkui1_logon_domain As Long
'list of other domains browsed by the workstation
wkui1_oth_domains As Long
'name of the authenticating server
wkui1_logon_server As Long
End Type
....
Dim typNTInfo As WKSTA_USER_INFO_1
'call the NetWkstaUserGetInfo API specifying a level 1 information
structure
lngRet = apiWkStationUser(0&, 1&, lngPtr)
If lngRet = NERR_Success And lngPtr Then
Call sapiCopyMemory(typNTInfo, ByVal lngPtr, LenB(typNTInfo))
If Not IsNull(lngPtr) Then
With typNTInfo
glbUserName = fStringFromPtr(.wkui1_username)
glbDomainName = fStringFromPtr(.wkui1_logon_domain)
glbServerName = fStringFromPtr(.wkui1_logon_server)
glbOtherDomains = fStringFromPtr(.wkui1_oth_domains)
End With
End If
End If





All times are GMT +1. The time now is 10:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com