Capturing Windows Login with ASP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dave

    Capturing Windows Login with ASP

    Hi I have succesfully captured the users login detail, but I now
    have a new problem I have assigned the login to a Session Variable, however
    when I come to use the string stored in the variable it excludes the \ which
    seperates the domain from the user name, it should be :DOMAIN\USERNAM E , but
    I am getting DOMAINUSERNAME which really is a pain. Anybody
    know why this is happening and how I can overcome it ?

    Thanks


  • Harag

    #2
    Re: Capturing Windows Login with ASP

    On Mon, 13 Sep 2004 08:17:57 +0000 (UTC), "dave"
    <dave@griffinen g.co.uk> wrote:
    [color=blue]
    >Hi I have succesfully captured the users login detail, but I now
    >have a new problem I have assigned the login to a Session Variable, however
    >when I come to use the string stored in the variable it excludes the \ which
    >seperates the domain from the user name, it should be :DOMAIN\USERNAM E , but
    >I am getting DOMAINUSERNAME which really is a pain. Anybody
    >know why this is happening and how I can overcome it ?
    >
    >Thanks
    >[/color]

    are you using vbscript or jscript?

    I guess jscript. "\" is the esc chr for jscript, you might need to
    replace it with 2 "\\"

    hth

    al.

    Comment

    • dave

      #3
      Re: Capturing Windows Login with ASP

      "Harag" <haragREMOVETHE SECAPITALS@soft home.net> wrote in message
      news:4emak05k10 6kehcp3f92q8apt hnuee33tk@4ax.c om...[color=blue]
      > On Mon, 13 Sep 2004 08:17:57 +0000 (UTC), "dave"
      > <dave@griffinen g.co.uk> wrote:
      >[color=green]
      >>Hi I have succesfully captured the users login detail, but I now
      >>have a new problem I have assigned the login to a Session Variable,
      >>however
      >>when I come to use the string stored in the variable it excludes the \
      >>which
      >>seperates the domain from the user name, it should be :DOMAIN\USERNAM E ,
      >>but
      >>I am getting DOMAINUSERNAME which really is a pain. Anybody
      >>know why this is happening and how I can overcome it ?
      >>
      >>Thanks
      >>[/color]
      >
      > are you using vbscript or jscript?
      >
      > I guess jscript. "\" is the esc chr for jscript, you might need to
      > replace it with 2 "\\"
      >
      > hth
      >
      > al.
      >[/color]

      vbscript


      Comment

      • dave

        #4
        Re: Capturing Windows Login with ASP

        "Harag" <haragREMOVETHE SECAPITALS@soft home.net> wrote in message
        news:4emak05k10 6kehcp3f92q8apt hnuee33tk@4ax.c om...[color=blue]
        > On Mon, 13 Sep 2004 08:17:57 +0000 (UTC), "dave"
        > <dave@griffinen g.co.uk> wrote:
        >[color=green]
        >>Hi I have succesfully captured the users login detail, but I now
        >>have a new problem I have assigned the login to a Session Variable,
        >>however
        >>when I come to use the string stored in the variable it excludes the \
        >>which
        >>seperates the domain from the user name, it should be :DOMAIN\USERNAM E ,
        >>but
        >>I am getting DOMAINUSERNAME which really is a pain. Anybody
        >>know why this is happening and how I can overcome it ?
        >>
        >>Thanks
        >>[/color]
        >
        > are you using vbscript or jscript?
        >
        > I guess jscript. "\" is the esc chr for jscript, you might need to
        > replace it with 2 "\\"
        >
        > hth
        >
        > al.
        >[/color]

        I have just realised that my problem lies elsewhere ! I am holding the user
        login in a table which is passed to a new webpage via the URL and I am
        reading the the variable from the query string ! This is where the character
        is getting lost I believe, but I still do not know how to cure, so any more
        help would be gratefully received.

        Thanks

        Dave


        Comment

        • Harag

          #5
          Re: Capturing Windows Login with ASP

          On Mon, 13 Sep 2004 09:07:07 +0000 (UTC), "dave"
          <dave@griffinen g.co.uk> wrote:
          [color=blue]
          >"Harag" <haragREMOVETHE SECAPITALS@soft home.net> wrote in message
          >news:4emak05k1 06kehcp3f92q8ap thnuee33tk@4ax. com...[color=green]
          >> On Mon, 13 Sep 2004 08:17:57 +0000 (UTC), "dave"
          >> <dave@griffinen g.co.uk> wrote:
          >>[color=darkred]
          >>>Hi I have succesfully captured the users login detail, but I now
          >>>have a new problem I have assigned the login to a Session Variable,
          >>>however
          >>>when I come to use the string stored in the variable it excludes the \
          >>>which
          >>>seperates the domain from the user name, it should be :DOMAIN\USERNAM E ,
          >>>but
          >>>I am getting DOMAINUSERNAME which really is a pain. Anybody
          >>>know why this is happening and how I can overcome it ?
          >>>
          >>>Thanks
          >>>[/color]
          >>
          >> are you using vbscript or jscript?
          >>
          >> I guess jscript. "\" is the esc chr for jscript, you might need to
          >> replace it with 2 "\\"
          >>
          >> hth
          >>
          >> al.
          >>[/color]
          >
          >I have just realised that my problem lies elsewhere ! I am holding the user
          >login in a table which is passed to a new webpage via the URL and I am
          >reading the the variable from the query string ! This is where the character
          >is getting lost I believe, but I still do not know how to cure, so any more
          >help would be gratefully received.
          >
          >Thanks
          >
          >Dave
          >[/color]


          are you encoding the querystring?

          <a href="mypage.as p?sting=<%= Server.URLEncod e("domain\user" )
          %>">click me</a>


          Comment

          • JP SIngh

            #6
            Re: Capturing Windows Login with ASP

            Try this

            sFullUser = trim(Request.Se rverVariables ("LOGON_USER "))
            sFullUser = replace(sFullUs er,"/","\")
            iPos = InStr(sFullUser , "\")
            sDomain = Left(sFullUser, iPos - 1)
            strUserName = Mid(sFullUser, iPos + 1)


            make sure you have "Integrated Windows Auth" turned on your server



            "dave" <dave@griffinen g.co.uk> wrote in message
            news:ci3l3l$g0q $1@sparta.btint ernet.com...[color=blue]
            > Hi I have succesfully captured the users login detail, but I now
            > have a new problem I have assigned the login to a Session Variable,[/color]
            however[color=blue]
            > when I come to use the string stored in the variable it excludes the \[/color]
            which[color=blue]
            > seperates the domain from the user name, it should be :DOMAIN\USERNAM E ,[/color]
            but[color=blue]
            > I am getting DOMAINUSERNAME which really is a pain. Anybody
            > know why this is happening and how I can overcome it ?
            >
            > Thanks
            >
            >[/color]


            Comment

            • Jeff Cochran

              #7
              Re: Capturing Windows Login with ASP

              On Mon, 13 Sep 2004 09:07:07 +0000 (UTC), "dave"
              <dave@griffinen g.co.uk> wrote:
              [color=blue]
              >"Harag" <haragREMOVETHE SECAPITALS@soft home.net> wrote in message
              >news:4emak05k1 06kehcp3f92q8ap thnuee33tk@4ax. com...[color=green]
              >> On Mon, 13 Sep 2004 08:17:57 +0000 (UTC), "dave"
              >> <dave@griffinen g.co.uk> wrote:
              >>[color=darkred]
              >>>Hi I have succesfully captured the users login detail, but I now
              >>>have a new problem I have assigned the login to a Session Variable,
              >>>however
              >>>when I come to use the string stored in the variable it excludes the \
              >>>which
              >>>seperates the domain from the user name, it should be :DOMAIN\USERNAM E ,
              >>>but
              >>>I am getting DOMAINUSERNAME which really is a pain. Anybody
              >>>know why this is happening and how I can overcome it ?
              >>>
              >>>Thanks
              >>>[/color]
              >>
              >> are you using vbscript or jscript?
              >>
              >> I guess jscript. "\" is the esc chr for jscript, you might need to
              >> replace it with 2 "\\"
              >>
              >> hth
              >>
              >> al.
              >>[/color]
              >
              >I have just realised that my problem lies elsewhere ! I am holding the user
              >login in a table which is passed to a new webpage via the URL and I am
              >reading the the variable from the query string ! This is where the character
              >is getting lost I believe, but I still do not know how to cure, so any more
              >help would be gratefully received.[/color]

              Either encode the query string, using HTMLEncode or URLEncode, or what
              I do is split the string to domain and user and store them separately.

              Jeff

              Comment

              • dave

                #8
                Re: Capturing Windows Login with ASP

                "Jeff Cochran" <jeff.nospam@zi na.com> wrote in message
                news:41469e76.1 785386710@msnew s.microsoft.com ...[color=blue]
                > On Mon, 13 Sep 2004 09:07:07 +0000 (UTC), "dave"
                > <dave@griffinen g.co.uk> wrote:
                >[color=green]
                >>"Harag" <haragREMOVETHE SECAPITALS@soft home.net> wrote in message
                >>news:4emak05k 106kehcp3f92q8a pthnuee33tk@4ax .com...[color=darkred]
                >>> On Mon, 13 Sep 2004 08:17:57 +0000 (UTC), "dave"
                >>> <dave@griffinen g.co.uk> wrote:
                >>>
                >>>>Hi I have succesfully captured the users login detail, but I now
                >>>>have a new problem I have assigned the login to a Session Variable,
                >>>>however
                >>>>when I come to use the string stored in the variable it excludes the \
                >>>>which
                >>>>seperates the domain from the user name, it should be :DOMAIN\USERNAM E ,
                >>>>but
                >>>>I am getting DOMAINUSERNAME which really is a pain. Anybody
                >>>>know why this is happening and how I can overcome it ?
                >>>>
                >>>>Thanks
                >>>>
                >>>
                >>> are you using vbscript or jscript?
                >>>
                >>> I guess jscript. "\" is the esc chr for jscript, you might need to
                >>> replace it with 2 "\\"
                >>>
                >>> hth
                >>>
                >>> al.
                >>>[/color]
                >>
                >>I have just realised that my problem lies elsewhere ! I am holding the
                >>user
                >>login in a table which is passed to a new webpage via the URL and I am
                >>reading the the variable from the query string ! This is where the
                >>character
                >>is getting lost I believe, but I still do not know how to cure, so any
                >>more
                >>help would be gratefully received.[/color]
                >
                > Either encode the query string, using HTMLEncode or URLEncode, or what
                > I do is split the string to domain and user and store them separately.
                >
                > Jeff[/color]

                Excuse my ignorance, but how do I split the string ? as I feel this would be
                the best way forward.

                Dave


                Comment

                • Harag

                  #9
                  Re: Capturing Windows Login with ASP

                  On Mon, 13 Sep 2004 16:05:32 +0000 (UTC), "dave"
                  <dave@griffinen g.co.uk> wrote:

                  [snipped a load of lines]
                  [color=blue][color=green]
                  >> Jeff[/color]
                  >
                  >Excuse my ignorance, but how do I split the string ? as I feel this would be
                  >the best way forward.
                  >
                  >Dave[/color]

                  Extracted from the MS scripting documents v5.6

                  HTH
                  Al.

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


                  Returns a zero-based, one-dimensional array containing a specified
                  number of substrings.

                  Split(expressio n[, delimiter[, count[, compare]]])
                  Arguments
                  expression
                  Required. String expression containing substrings and delimiters. If
                  expression is a zero-length string, Split returns an empty array, that
                  is, an array with no elements and no data.
                  delimiter
                  Optional. String character used to identify substring limits. If
                  omitted, the space character (" ") is assumed to be the delimiter. If
                  delimiter is a zero-length string, a single-element array containing
                  the entire expression string is returned.
                  count
                  Optional. Number of substrings to be returned; -1 indicates that all
                  substrings are returned.
                  compare
                  Optional. Numeric value indicating the kind of comparison to use when
                  evaluating substrings. See Settings section for values.
                  Settings
                  The compare argument can have the following values:

                  Constant Value Description
                  vbBinaryCompare 0 Perform a binary comparison.
                  vbTextCompare 1 Perform a textual comparison.

                  Remarks
                  The following example uses the Split function to return an array from
                  a string. The function performs a textual comparison of the delimiter,
                  and returns all of the substrings.

                  Dim MyString, MyArray, Msg
                  MyString = "VBScriptXisXfu n!"
                  MyArray = Split(MyString, "x", -1, 1)
                  ' MyArray(0) contains "VBScript".
                  ' MyArray(1) contains "is".
                  ' MyArray(2) contains "fun!".
                  Msg = MyArray(0) & " " & MyArray(1)
                  Msg = Msg & " " & MyArray(2)
                  MsgBox Msg
                  [color=blue]
                  >[/color]

                  Comment

                  • Dave

                    #10
                    Re: Capturing Windows Login with ASP

                    Thanks guys, has sorted out my problems. Cant thank you all enough !

                    Dave
                    "JP SIngh" <none@none.co m> wrote in message
                    news:%23qtyu7Xm EHA.896@TK2MSFT NGP12.phx.gbl.. .[color=blue]
                    > Try this
                    >
                    > sFullUser = trim(Request.Se rverVariables ("LOGON_USER "))
                    > sFullUser = replace(sFullUs er,"/","\")
                    > iPos = InStr(sFullUser , "\")
                    > sDomain = Left(sFullUser, iPos - 1)
                    > strUserName = Mid(sFullUser, iPos + 1)
                    >
                    >
                    > make sure you have "Integrated Windows Auth" turned on your server
                    >
                    >
                    >
                    > "dave" <dave@griffinen g.co.uk> wrote in message
                    > news:ci3l3l$g0q $1@sparta.btint ernet.com...[color=green]
                    > > Hi I have succesfully captured the users login detail, but I now
                    > > have a new problem I have assigned the login to a Session Variable,[/color]
                    > however[color=green]
                    > > when I come to use the string stored in the variable it excludes the \[/color]
                    > which[color=green]
                    > > seperates the domain from the user name, it should be :DOMAIN\USERNAM E ,[/color]
                    > but[color=green]
                    > > I am getting DOMAINUSERNAME which really is a pain. Anybody
                    > > know why this is happening and how I can overcome it ?
                    > >
                    > > Thanks
                    > >
                    > >[/color]
                    >
                    >[/color]


                    Comment

                    • Jeff Cochran

                      #11
                      Re: Capturing Windows Login with ASP

                      >> Either encode the query string, using HTMLEncode or URLEncode, or what[color=blue][color=green]
                      >> I do is split the string to domain and user and store them separately.[/color][/color]
                      [color=blue]
                      >Excuse my ignorance, but how do I split the string ? as I feel this would be
                      >the best way forward.[/color]

                      I use:

                      strLogonUser = Request.ServerV ariables("LOGON _USER")
                      tmpUserID = Split(strLogonU ser,"\")
                      strUserDomain = tmpUserID(0)
                      strUserName = tmpUserID(1)

                      Now you can use UserName, UserDomain or LogonUser, whichever is
                      appropriate for your needs.

                      Jeff

                      Comment

                      Working...