node.js - 如何在不出现用户名密码提示的情况下从 windows auth 获取 LOGON_USER 信息?
问题描述
我正在使用 iisnode 在 Windows Server 2016 上运行我的 express、nodejs 应用程序。我只需要连接到我的应用程序的客户端计算机的 LOGON_USER(用户名)(这是在公司网络上)。连接到我的应用程序时,它会提示用户输入用户名密码。我的理解是,当使用 Windows 身份验证时,我可以访问客户端凭据而无需他们登录我的应用程序,因为他们已经登录到他们的计算机?
我在默认网站下的应用程序的 IIS 中禁用了匿名身份验证并启用了 Windows 身份验证。我已按照这些说明推广一些服务器变量 ex。登录用户。当我浏览我的应用程序站点时,系统会提示我登录名和用户名弹出窗口。在不让他们再次提供凭据的情况下,我需要做什么才能访问客户的用户名/计算机名称。我什至不需要对他们进行身份验证我只需要他们正在访问我的应用程序的计算机上的用户名。
网络配置。
</appSettings>
<system.webServer>
<!-- Remove the modules element if running on IIS 8.5-->
<modules runAllManagedModulesForAllRequests="false" />
<!-- <httpErrors existingReponse="PassThrough"></httpErrors> -->
<iisnode node_env="%node_env%"
nodeProcessCountPerApplication="1"
maxConcurrentRequestsPerProcess="1024"
maxNamedPipeConnectionRetry="100"
namedPipeConnectionRetryDelay="250"
maxNamedPipeConnectionPoolSize="512"
maxNamedPipePooledConnectionAge="30000"
asyncCompletionThreadCount="0"
initialRequestBufferSize="4096"
maxRequestBufferSize="65536"
uncFileChangesPollingInterval="5000"
gracefulShutdownTimeout="60000"
loggingEnabled="true" logDirectory="iisnode"
debuggingEnabled="true" d
ebugHeaderEnabled="false"
debuggerPortRange="5058-6058"
debuggerPathSegment="debug"
maxLogFileSizeInKB="128"
maxTotalLogFileSizeInKB="1024"
maxLogFiles="20"
devErrorsEnabled="true"
flushResponse="false"
enableXFF="false"
promoteServerVars="AUTH_USER,AUTH_TYPE,LOGON_USER,REMOTE_USER,REMOTE_HOST"
configOverrides="iisnode.yml"
watchedFiles="web.config;*.js"
nodeProcessCommandLine="C:\Program Files\nodejs\node.exe" />
<handlers>
<add name="iisnode" path="server/dist/index.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<!-- Don't interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^server/dist/index.js\/debug[\/]?" />
</rule>
<!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
<rule name="StaticContent" patternSyntax="Wildcard">
<action type="Rewrite" url="client/build/{R:0}" logRewrittenUrl="true" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<match url="*.*" />
</rule>
<!-- All other URLs are mapped to the Node.js application entry point -->
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" />
</conditions>
<action type="Rewrite" url="server/dist/index.js" />
</rule>
</rules>
</rewrite>
<directoryBrowse enabled="false" />
</system.webServer>
<system.web>
<authentication mode="Windows" />
<authorization>
<allow users="*" />
<deny users="?" />
</authorization>
<identity impersonate="false" />
</system.web>
解决方案
呃……想通了。我正在使用我的网站http://ip.address/myapp的 IP 地址。如果网址中有句点,它将始终提示输入登录名和密码。因此,我将 ip 设置为服务器名称并解决了问题。http://myservername/myapp
推荐阅读
- r - 为什么 ggplotly 会在我闪亮的应用程序中切断图例?
- javascript - 检索firebase数据库json
- c# - Linq查询根据特殊条件分组
- rust - 如何使用 Serde 将字段解析为字符串?
- node.js - 在 gulp 中获取祖父母目录名称
- mysql - 默认 AUTH 凭据不匹配 Laravel
- pervasive-sql - Pervasive SQL 中不区分大小写的 LIKE 子句
- python-3.x - 从 Facebook 帖子中删除原始链接和标题
- kubernetes - Kubernetes 滚动更新不停机?
- python - 将 np.where 应用于方括号过滤以进行 numpy 过滤