Retrieving Novell NetWare username and passing it to a label

Posted on 2003-03-05
Medium Priority
Last Modified: 2012-06-22
There is another thread here somewhere that was asking how he could retrieve the novell network username with 2000/XP machines (i can only retrive the local machine username at this point) and it was agreed the best method was to use:
Debug.Print Environ("nwusername")

However, being the beginner that i am, i can't get this value to display anywhere. What i want to do is use that line of code to get the username and then pass the value to a label to be displayed on my form. I hope this makes sense (it doesn't make much to me)? Even if i can get the value into a variable or something i can go from there.

Question by:marzi
  • 2
LVL 41

Accepted Solution

shanesuebsahakarn earned 200 total points
ID: 8079509
You can use some code like this in the OnOpen event of the form:
Me!MyLabel.Caption = environ("nwusername")
LVL 18

Expert Comment

ID: 8080069
Try this:

Declare Function WNetGetUser& Lib "mpr.dll" Alias "WNetGetUserA" (ByVal lpName$, ByVal lpUserName$, BufLen&)

Public Function GetNovellUserID()
    Dim lpName As String, NovellUserLoginID As String
    NovellUserLoginID = Space$(55)
    WNetGetUser& lpName$, NovellUserLoginID, Len(NovellUserLoginID)
    GetNovellUserID = Left$(NovellUserLoginID, InStr(NovellUserLoginID, Chr$(0)) - 1)
End Function

Private Sub ShowMe()

    MsgBox GetNovellUserID()
End Sub

Author Comment

ID: 8083994
I'm not overly skilled in vb... but i can gaurantee you i should have really something other than debug.print should could equal the variable. I was thinking of it as a whole statement... pretty stupid :-)

Thanks shane... you right on the $$$.

Author Comment

ID: 8084002
That meant to say... but i can gaurantee you i should have realised something other than debug.print can equal the variable...

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I have had my own IT business for a very long time. I started mostly with hardware and after about a year started to notice a common theme. I had shelves with software boxes -- Peachtree, Quicken, Sage, Ouickbooks -- and yet most of my clients were…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

615 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