Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bundles/iis_ad_asp_jwt.zip
Binary file not shown.
30 changes: 28 additions & 2 deletions classic_asp_jwt_with_ad.asp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,32 @@ Function JWTTokenForUser(dAttributes)
JWTTokenForUser = JWTEncode(dAttributes, sKey)
End Function

Function Encode_UTF8(astr)

utftext = ""

For n = 1 To Len(astr)
c = AscW(Mid(astr, n, 1))
If c < 128 Then
utftext = utftext + Mid(astr, n, 1)
ElseIf ((c > 127) And (c < 2048)) Then
utftext = utftext + Chr(((c \ 64) Or 192))
'((c>>6)|192);
utftext = utftext + Chr(((c And 63) Or 128))
'((c&63)|128);}
Else
utftext = utftext + Chr(((c \ 144) Or 234))
'((c>>12)|224);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to line up with what's being done in the line above...
1<<12 is 4096 and 224 != 234 :)
Maybe a simple function to help test & sanity check the encoding?

utftext = utftext + Chr((((c \ 64) And 63) Or 128))
'(((c>>6)&63)|128);
utftext = utftext + Chr(((c And 63) Or 128))
'((c&63)|128);
End If
Next

Encode_UTF8 = utftext
End Function

Function Debug(sMessage)
If dM Then
response.Write("[DEBUG] " & sMessage & "<br/>")
Expand Down Expand Up @@ -123,15 +149,15 @@ Function GetAuthenticatedUser()
If Not userRS.EOF and not err then
Set dAttributes = Server.CreateObject("Scripting.Dictionary")

dAttributes.Add "name", userRS("displayName").Value
dAttributes.Add "name", Encode_UTF8(userRS("displayName").Value)
dAttributes.Add "email", userRS("mail").Value

If sExternalIdField > "" Then
dAttributes.Add "external_id", userRS(sExternalIdField).Value
End If

If sOrganizationField > "" Then
dAttributes.Add "organization", userRS(sOrganizationField).Value
dAttributes.Add "organization", Encode_UTF8(userRS(sOrganizationField).Value)
End If

If sTagsField > "" Then
Expand Down