Username not working on NT workstation

Username not working on NT workstation

Post by Theminh Die » Tue, 27 Jan 1998 04:00:00



Hi friends,

The code below retreives Novell user name from Win95 but doesn't
retreive it from NT workstation. Anybody has an idea why? Should I build
a different function for NT stations?

-----------Code begins here-------------

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

    lngBufferLength = 9
    lngRet = GetUserName(strBuffer, lngBufferLength)
    strTemp = UCase(Trim$(strBuffer))
    NTDomainUserName = Left(strTemp, InStr(strTemp, Chr(0)) - 1)

   End Function

-----------Code ends here-------------
--
T h e m i n h  D i e p
Programmer-analyst / Programmeur-analyste

National Research Council Canada / Conseil national de recherches Canada

Biothechnology Research Institute / Institut de recherche en
biotechnologie



 
 
 

Username not working on NT workstation

Post by sen.. » Sat, 31 Jan 1998 04:00:00


sure...
try this...

    Dim lResult As Long
    Dim lSize As Long
    Dim szName As String

    szName = Space(254)
    lSize = Len(szName) + 1
    lResult = GetUserName(szName, lSize)
    If lResult = 0 Then
        Msgbox  "Function failed!"
        Else
        Msgbox  szName
        End If

The reason I use 254, is basically because many API's require a
maximum size of anything, which like directories can be quite large.
Although you only need to set it to 16 (15 is the max user name, +1
for the Null terminator), this works very well nonetheless.



>Hi friends,

>The code below retreives Novell user name from Win95 but doesn't
>retreive it from NT workstation. Anybody has an idea why? Should I build
>a different function for NT stations?

>-----------Code begins here-------------

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

>    lngBufferLength = 9
>    lngRet = GetUserName(strBuffer, lngBufferLength)
>    strTemp = UCase(Trim$(strBuffer))
>    NTDomainUserName = Left(strTemp, InStr(strTemp, Chr(0)) - 1)

>   End Function

>-----------Code ends here-------------
>--
>T h e m i n h  D i e p
>Programmer-analyst / Programmeur-analyste

>National Research Council Canada / Conseil national de recherches Canada

>Biothechnology Research Institute / Institut de recherche en
>biotechnologie





 
 
 

1. Help, GUI tools not working anymore - SQL7 SP3 - Workstation NT 4.0 SP6a

I apologize in advance for the repeat, I posted this question to other
newsgroups in order to figure out a quick fix/solution.

Since I installed SP3 yesterday morning, I can't open up Enterprise
Manager (mmc 1.1) and I can't open Query Analyzer.
I get the snap-in error with EM and "SQLGUIGetOS not located in
SQLGUI.dll"
error with Query Analyzer.

I do know that the data are not corrupted, at least at first sight:
I was able to link tables from an MS Access file (to the Northwind
DB).

Enterprise Manager is the only application that uses MMC on my
workstation.

Is there a fix or workaround?

I tried to reinstall SP6a on NT workstation: nothing changed
I tried to reinstall MDAC 2.5: nothing changed.
I tried to reinstall MMC 1.1: nothing changed.

Please, help me,

Thanks in advance,

Isabelle

2. compile failure

3. ODBC works in w98 not in NT Workstation

4. Update Gram Delete

5. What versions of Oracle Server work on NT Workstation

6. Converting C header files to Delphi

7. DB2 working distributed on Windoes NT Workstations

8. Initializing Access To Network Files

9. sql enterprise manger's rigester server doesn't work in a nt workstation

10. NT Workstation installation works but program fails

11. does the replication works with NT workstation?

12. BCP can't work in windows NT workstation 4.0

13. Does 6.5 work on NT 4.0 Workstation?