Solved

Getting UserName Password

Posted on 1998-11-12
4
221 Views
Last Modified: 2010-04-30
Hello all I need to get the username and password of the current user for a Win 95 or Win 98 or Win NT system.  I need this information to pass it along to the SQL Server as the UID and PWD
0
Comment
Question by:cavacasp
[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
4 Comments
 
LVL 3

Expert Comment

by:vmano
ID: 1444581
i can give you the code for getting the UserName from NT.
Type the following code into a new module:

' Makes sure all variables are dimensioned in each subroutine.
Option Explicit
 
' Access the GetUserNameA function in advapi32.dll and
' call the function GetUserName.
Declare Function GetUserName Lib "advapi32.dll" Alias  "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
 
' Main routine to Dimension variables, retrieve user name
' and display answer.
Sub Get_User_Name()
     Dim lpBuff As String * 25
     Dim ret As Long, UserName As String
 
' Get the user name minus any trailing spaces found in the name.
     ret = GetUserName(lpBuff, 25)
     UserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
 
' Display the User Name
     MsgBox UserName
End Sub

let me find out the other one for you (or) somebody else will give you.
vmano
0
 
LVL 3

Expert Comment

by:HATCHET
ID: 1444582
cavacasp,

Put the following in a sub or function where needed :
-----------------------------------------------------

  Dim strTheString As String
  Dim lngLength As Long
  Dim lngResult As Long
  Dim CurUser As String
 
  lngLength = 199
  strTheString = String(200, 0)
  lngResult = GetUserName(strTheString, lngLength)
  If lngResult <> 0 Then
    CurUser = Left(strTheString, lngLength - 1)
  Else
    CurUser = ""
  End If
 
  MsgBox "Current user = " & CurUser, vbOKOnly + vbInformation, ""


Put the following in a module:
------------------------------

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


This should work on Win95, Win98, and WinNT but you should test it.

HATCHET
0
 

Author Comment

by:cavacasp
ID: 1444583
I need username and password or it does not help me.
0
 
LVL 2

Accepted Solution

by:
Poddy earned 70 total points
ID: 1444584
Use integrated security on your SQL Server.

The only way to get the password is to get the user to enter it
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

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