How to get the domain name

  • Thread starter Thread starter Peter Ramsebner
  • Start date Start date
Try the following:

Option Compare Database
Option Explicit

' Description: Get the user's network login name. Works with both Novell and
Microsoft networking under NT 3.51, NT4, Win95, Win98 and Win2000. Thanks to
Wade Jackson at Microsoft for some useful info.
' --------------------------------------------------------------------------
------

' By Chris Rae, 14/6/99, 3/9/00.

' This is used by GetUserName() to find the current user's
' name from the API
Declare Function Get_User_Name Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, _
nSize As Long) As Long

Private Function GetUserName() As String
Dim lpBuff As String * 25

Get_User_Name lpBuff, 25
GetUserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
End Function
 
AFAIK, that only returns the user ID, not the domain to which the user ID
belongs.

To get the domain, see the code in
http://www.mvps.org/access/api/api0040.htm at "The Access Web".

That, of course, assumes that the original poster is looking for the user's
domain, and not the domain to which the server belongs...

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Sylvain Lafontaine said:
Try the following:

Option Compare Database
Option Explicit

' Description: Get the user's network login name. Works with both Novell and
Microsoft networking under NT 3.51, NT4, Win95, Win98 and Win2000. Thanks to
Wade Jackson at Microsoft for some useful info.
' --------------------------------------------------------------------------
 
I'm sorry, I was thinking that the user name returned by this fonction was
prefixed with the domain name and I didn't take the time to make the
verification on a LAN with a domain server.

S. L.

Douglas J. Steele said:
AFAIK, that only returns the user ID, not the domain to which the user ID
belongs.

To get the domain, see the code in
http://www.mvps.org/access/api/api0040.htm at "The Access Web".

That, of course, assumes that the original poster is looking for the user's
domain, and not the domain to which the server belongs...

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



Thanks
' --------------------------------------------------------------------------
 
Back
Top