Solved

Grab NT Username, Password AND NT Group

Posted on 2001-09-07
13
406 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
Technology Partners: 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!

 
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

685 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