开发者

Getting environment variable LOGONSERVER in an ASP/MVC application

开发者 https://www.devze.com 2023-02-19 12:09 出处:网络
I know how to get the LOGONSERVER environment variable via this: Environment.GetEnvironmentVariable(\"LOGONSERVER\");

I know how to get the LOGONSERVER environment variable via this:

Environment.GetEnvironmentVariable("LOGONSERVER");
开发者_运维技巧

However, if my application is an ASP/MVC3 application, this is going to give me the logon server for the box that IIS is running on right? Not the logonserver for the browser who's request I am processing. I know I can use this to get the users logon name server-side

HttpContext.ApplicationInstance.Context.User.Identity.Name

But I don't see anything in that namespace that will give me logonserver either.

I now I can grab it client-side via javascript but I have to execute a CreateObject which will force the "ActiveX" authorization request in the browser.

Any other ideas?


I have been trying to find a way around this, and eventually put this shared function into the Global.asax.

    Public Shared Function GetDC() As String
        'Determine DNS domain name from RootDSE object
        Dim objRootDSE As Object = GetObject("LDAP://<myDomain>/RootDSE")
        Dim strNamingContext As String = objRootDSE.Get("rootDomainNamingContext")
        Dim lcDC As Object = objRootDSE.Get("dnsHostName")

        Return lcDC.ToString()
    End Function

You can then use it <%= MyGlobalAsaxClassName.GetDC() %>

0

精彩评论

暂无评论...
验证码 换一张
取 消