Solved

Grab NT Username, Password AND NT Group

Posted on 2001-09-07
13
397 Views
Last Modified: 2008-02-01
I making a web application for an Intranet.  I come from Inernet development and have never dealt with obtaining a users NT information before.  What I want ideally is to have my component grab the user's NT login AND the NT Group they reside in.  I will manage with just the NT Login Info is grabbing the NT Group is not possible.  Does anyone have an example of how to grab this info over an intranet?
0
Comment
Question by:scotiaceilidh
  • 6
  • 3
  • 3
  • +1
13 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6464885
Declare Function GetUserNameA Lib "ADVAPI32" (ByVal lpBuffer As String, nSize As Long) As Long
Function GetLoginName() As String
Dim iBufSize As Long
Dim sUser As String

iBufSize = 255
sUser = Space$(iBufSize)
If GetUserNameA(sUser, iBufSize) = 1 Then
   GetLoginName = Left$(sUser, iBufSize - 1)
Else
   GetLoginName = "??????"
End If

End Function

Anthony
0
 
LVL 5

Accepted Solution

by:
rkot2000 earned 220 total points
ID: 6464899
you can use server variables to get user id and domain:


http://www.asp101.com/samples/servvars.asp

i am using the following 2 functions in my asp pages to get userid and domain.

     Public Function LogonUserNTID()
     
          dim lvsLogonUser
          dim lasLogonUser
          lvsLogonUser= Request.ServerVariables("LOGON_USER")
          lasLogonUser= Split(lvsLogonUser,"\")
          LogonUserNTID = lasLogonUser(1)
         
     End Function

     Public Function LogonUserNTDomain()
          dim lvsLogonUser
          dim lasLogonUser
          lvsLogonUser= Request.ServerVariables("LOGON_USER")
          lasLogonUser= Split(lvsLogonUser,"\")
          LogonUserNTDomain = lasLogonUser(0)
     
     End Function
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6464924
There is a sample app on http://www.geocities.com/TimCottee goto downloads. It will determine the NT groups that a user belongs to given the user name from above examples. Getting the password is basically not feasible as it is never stored in plain-text anywhere to be retrieved.
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 1

Author Comment

by:scotiaceilidh
ID: 6465106
Wow, Thank you.  I get back from lunch and...   I have a couple hours of meetings and will be right back to get on all this.
0
 
LVL 1

Author Comment

by:scotiaceilidh
ID: 6465719
rkot2000, I am getting this error on your code and have not been able to use it as of yet.

Microsoft VBScript runtime (0x800A0009)
Subscript out of range: '[number: 1]'

acperkins,
I did get your code to work.  Any idea how to the Domain?  That's what I need now, as the Userid's may not be unique.


0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6465865
Take a look at TimCottee code it shows you all the NT Groups the user belongs to.

Anthony
0
 
LVL 5

Expert Comment

by:rkot2000
ID: 6470758
you need to remove Allow Anonymous Access
and to check Windows NT Challenge/Response  

The user?s Web browser does not send actual Windows NT account password information across the network.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6470806
rkot2000,

Comment posted to the wrong question, perhaps?

Anthony
0
 
LVL 5

Expert Comment

by:rkot2000
ID: 6470815
nop by default a web site has Allow Anonymous Access in the security tab so logon_user is empty.





0
 
LVL 5

Expert Comment

by:rkot2000
ID: 6470827
PRB: Request.ServerVariables("LOGON_USER") Returns Empty String

ID: Q188717


--------------------------------------------------------------------------------
The information in this article applies to:

Active Server Pages
Microsoft Internet Information Server versions 4.0, 5.0

--------------------------------------------------------------------------------


SYMPTOMS
Accessing the Request.ServerVariables("LOGON_USER") variable from Active Server Pages (ASP) returns an empty string.



CAUSE
The LOGON_USER variable is not populated if the ASP page is accessed using Allow Anonymous security.

In order for the LOGON_USER variable to be populated, the user must be authenticated using either Basic or NT Challenge/Response security.



STATUS
This behavior is by design.



REFERENCES
For additional information, please see the following article in the Microsoft Knowledge Base:


Q142868 IIS: Authentication & Security Features

Additional query words: allow anonymous LOGON_USER ASP ServerVariables Request kbASP

0
 
LVL 5

Expert Comment

by:rkot2000
ID: 6470883
p.s you need to unload your website after all changes .
0
 
LVL 5

Expert Comment

by:rkot2000
ID: 6470895
you can use the following sample asp to check logon user:


<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>

<HR>
 <%=Request.ServerVariables("LOGON_USER")%>
<HR>

</BODY>
</HTML>
0
 
LVL 1

Author Comment

by:scotiaceilidh
ID: 6475313
Wish I could give More
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

810 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