Solved

Grab NT Username, Password AND NT Group

Posted on 2001-09-07
13
410 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
[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
  • 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
passing parameter in sql procedure 9 70
Problem to With line 4 87
VBA: Insert New column with specific format type 12 57
add criteria to query in VB, Access 2003 2 49
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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

752 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