Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

nt user

Posted on 2000-05-02
5
Medium Priority
?
170 Views
Last Modified: 2010-05-02
Is there a function that will get the current user of the domain.
All users are part of a NT domain therefor they are valid users.
I need to get there NT login name.
Any ideas?
0
Comment
Question by:chicabow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Expert Comment

by:pauljk
ID: 2771822
Try this...  Reject me if it doesn't work...

It's an API call...

Declare Function GetUserName& Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize as Long)




Dim s$,cnt&,dl&
cnt&=199
s$=String$(200,0)
dl&=GetUserName(s$,cnt)
Debug.Print Left$(s$,cnt);cnt
0
 
LVL 2

Expert Comment

by:Veroland
ID: 2771964
The api youre looking for is called
Public Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA" (ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long) As Long
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 75 total points
ID: 2771971
You can easily retrieve a user's network logon name by using the following API call:

Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long


To retrieve a "clean" version of the name, use this function:

Public Function NTDomainUserName() As String
Dim strBuffer As String * 255
Dim lngBufferLength As Long
Dim lngRet As Long
Dim strTemp As String

    lngBufferLength = 255
    lngRet = GetUserName(strBuffer, lngBufferLength)
    strTemp = UCase(Trim$(strBuffer))
    NTDomainUserName = Left$(strTemp, Len(strTemp) - 1)

End Function

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 2772288
Much easier:
try Environ("USERNAME") and
Environ("USERDOMAIN")
0
 
LVL 1

Author Comment

by:chicabow
ID: 2818757
This is the only one that worked with ease..

angelIII
Did not work...at all...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question