Solved

Grab NT Username, Password AND NT Group

Posted on 2001-09-07
13
385 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
 
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now