Getting NT user and group names to an ASP?

Results 1 to 4 of 4

Thread: Getting NT user and group names to an ASP?

  1. #1
    elaine pack Guest

    Default Getting NT user and group names to an ASP?

    We log our users into our network at boot time using NT security challenge. Our network is configured in such a way that this login gets passed to various other applications we run that require a login. We ask for a 2nd login on our Intranet, even tho it&#039;s usually the same as the main login info (this is by design--don&#039;t ask :)<BR><BR>However, I have an ASP webpage on which I&#039;d like to be able to retrieve some of the NT login info for use. I read one of the ASPFAQ and did figger out how to easily capture the NT Username, or rather, I guess it&#039;s the server login name from the 2nd login mentioned above, but not the NT Group name which I need in my ASP. I&#039;m not sure how this can be done. I don&#039;t need the password, just the username and group. From other messages here I know it can be done, but just not exactly how to do it :( <BR><BR>I was given a VB example that looks like this:<BR><BR>Private Declare Function GetUserName ib "advapi32.dll" alias_<BR> "GetUserNameA" (ByVal lpbuffer as String, nsize as Long) as Long<BR>.<BR>Public Sub Main()<BR> &#039;retrieve windows login name<BR>Dim buffer as String * 512, length as Long<BR>If GetuserName(buffer, Len(buffer)) then<BR> length = InStr(buffer, vbNullChar) - 1<BR> gstrUserName = Left$(buffer, length)<BR>end if<BR><BR>This means very little to me, unfortunately (I don&#039;t have VB on my machine), beyond the fact that it&#039;s pulling out the user name programmatically, which I already have, but not the group, apparently. <BR><BR>Can anyone suggest a hopefully easy way to get the NT security user and group names into an ASP? Or if there is another, perhaps better way to restrict access to some of our pages utilizing the NT security login, that would be good too. Please understand that I&#039;m essentially parroting most of the above as I&#039;m WAY out of my depth in dealing with NT and security issues so a simple explanation is appreciated also :) Make no assumptions about what I may know on these topics!! :) :)<BR><BR>Thanks!<BR><BR>elaine pack<BR><BR>

  2. #2
    Manjula Guest

    Default RE: Getting NT user and group names to an ASP?

    I have used the following scripts in my asp page, hope some of them may help you.<BR><BR>------------------------------------------------<BR>Set myObj = GetObject("WinNT://" & tmpLoginUser & ",user")<BR>strUserName = Mid(myobj.FullName,1,20)<BR><BR>Notes:<BR>This is to get the Login user&#039;s FULL NAME, here "" is the Domain Name, & tmpLoginUser holds the Login User&#039;s name<BR>------------------------------------------------<BR><BR>Set ADsGroup = GetObject("WinNT://,Group") <BR>For Each Member in ADsGroup.members <BR> response.write & & "<BR>"<BR>next<BR><BR>Notes:<BR>This is to get all the user names in the Group "COG"<BR>------------------------------------------------<BR><BR>Set myUser = GetObject("WinNT://adeweb/elan,user")<BR>Set userClass = GetObject(myUser.Schema)<BR>On Error Resume Next<BR>Response.Write "Mandatory properties for " & myUser.Name & ":" & "<BR>"<BR>For Each property In userClass.MandatoryProperties<BR> Response.Write " " & property & " : " & myUser.Get(property) & "<BR>"<BR>Next<BR>Response.Write "<BR>"<BR><BR>Response.Write "Optional properties for " & myUser.Name & ":" & "<BR>"<BR>For Each property In userClass.OptionalProperties<BR> Response.Write " " & property & " : " & myUser.Get(property) & "<BR>"<BR>Next<BR><BR>Notes:<BR>This gives all the properties for USER "elan" on the SERVER "adeweb"<BR>------------------------------------------------<BR><BR>Refference : MSDN Library<BR>

  3. #3
    elaine pack Guest

    Default RE: Getting NT user and group names to an ASP?

    Thanks for your response! I tried plugging in our values, but it didn&#039;t quite work however--obviously I&#039;m missing something! I&#039;ve run your code past my systems guy, and he had a question or two: <BR><BR>1. Will this code work with IIS 4? We are using simple NT4 domain security, according to him. Does it need Active Directories, etc? <BR>2. will this code work for someone who is logged in under the generic "iuser" account or are specific permissions needed to pull these values?<BR>3. I&#039;m getting a syntax error on the GetObject lines for some reason. The (sample) line:<BR>Set myObj = GetObject("WinNT://" & tmpLoginUser & ",user")<BR>changed to:<BR>Set myObj = GetObject ("WinNT://,user") gets me a syntax error--not sure if I should be using "winnt" or "http" or our actual internal name) but none worked. <BR><BR>Given the difficulty of finding stuff on the MSDN lib, especially now that they have redesigned it and all my bookmarks don&#039;t work :( can you give me an idea where you found this information there? I&#039;d like to research it further, but just don&#039;t quite know what to even search for :(<BR><BR>Thanks again!<BR>elaine<BR><B R><BR>

  4. #4
    Manjula Guest

    Default RE: Getting NT user and group names to an ASP?

    If you don&#039;t have MSDN Library check out this link ...<BR><BR><BR><BR>Here there is a link to MSDN Library, u can also try a search with the Keyword &#039;WINNT&#039;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts