« Previous Next »

Answered Thread: How to set authentication with appcmd.exe or ServerManager

Last post 09-17-2007 5:08 AM by steve schofield. 3 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (4 items)

Sort Posts:

  • 09-17-2007, 3:02 AM

    How to set authentication with appcmd.exe or ServerManager

    I'd like to set the authentication mode for a web site programaticly, can I do this by calling appcmd.exe with some nifty inparameters or using the Microsoft.Web.Administration.ServerManager object? (RawAttributes?)

    By authentication mode I mean anonymous, basic (clear text) or windows integrated. I've searched msdn but fail to find any information on this!.

    Thanks for any help! 

  • 09-17-2007, 4:22 AM In reply to

    Answered Re: How to set authentication with appcmd.exe or ServerManager

    For appcmd, you can set it via /section:xxxx. all auth schemes are locked except Form, so you either unlock it first or commit it at apphost level (meaning store the config in applicationHost.config, which is not so good as in xcopy deployment via web.config file.

    Example.
    appcmd set config "default web site" /section:windowsAuthentication /enabled:true /commit:apphost

    or unlock first:
    appcmd unlock config /section:windowsAuthentication
    appcmd set config "default web site" /section:windowsAuthentication /enabled:true

     

    Cheers,
    Bernard Cheah
  • 09-17-2007, 5:05 AM In reply to

    Answered Re: How to set authentication with appcmd.exe or ServerManager

    You should post your question in IIS7 - Extensibility.   http://forums.iis.net/1042.aspx 

    I would be interested in the answer also, I tried a few tries and kept bumping up against an index error.  Here is my code sample.  I manually set it in the GUI to see what the value stored in the applicationHost.config.    Here is what is stored.

        <location path="Default Web Site">
            <system.webServer>
                <security>
                    <authentication>
                        <basicAuthentication enabled="true" />
                    </authentication>
                </security>
            </system.webServer>
        </location>

    Here is my code sample.

    Dim objAuth As New Microsoft.Web.Administration.ServerManager
    objAuth.Sites(
    "Default Web Site").SetAttributeValue("basicAuthentication", False)
    objAuth.CommitChanges()

    This lists various commands in appcmd
    appcmd list sites -config -?

    C:\Windows\System32\inetsrv>appcmd list sites -config -?
    ERROR ( message:-name
    -id
    -serverAutoStart
    -bindings.[protocol='string',bindingInformation='string'].protocol
    -bindings.[protocol='string',bindingInformation='string'].bindingInformation
    -limits.maxBandwidth
    -limits.maxConnections
    -limits.connectionTimeout
    -logFile.logExtFileFlags
    -logFile.customLogPluginClsid
    -logFile.logFormat
    -logFile.directory
    -logFile.period
    -logFile.truncateSize
    -logFile.localTimeRollover
    -logFile.enabled
    -traceFailedRequestsLogging.enabled
    -traceFailedRequestsLogging.directory
    -traceFailedRequestsLogging.maxLogFiles
    -applicationDefaults.path
    -applicationDefaults.applicationPool
    -applicationDefaults.enabledProtocols
    -virtualDirectoryDefaults.path
    -virtualDirectoryDefaults.physicalPath
    -virtualDirectoryDefaults.userName
    -virtualDirectoryDefaults.password
    -virtualDirectoryDefaults.logonMethod
    -virtualDirectoryDefaults.allowSubDirConfig
    -[path='string'].path
    -[path='string'].applicationPool
    -[path='string'].enabledProtocols
    -[path='string'].virtualDirectoryDefaults.path
    -[path='string'].virtualDirectoryDefaults.physicalPath
    -[path='string'].virtualDirectoryDefaults.userName
    -[path='string'].virtualDirectoryDefaults.password
    -[path='string'].virtualDirectoryDefaults.logonMethod
    -[path='string'].virtualDirectoryDefaults.allowSubDirConfig
    -[path='string'].[path='string'].path
    -[path='string'].[path='string'].physicalPath
    -[path='string'].[path='string'].userName
    -[path='string'].[path='string'].password
    -[path='string'].[path='string'].logonMethod
    -[path='string'].[path='string'].allowSubDirConfig
     )

     

    Steve Schofield
    Windows Server MVP - IIS
    http://weblogs.asp.net/steveschofield


    http://www.IISLogs.com
    Log archival solution
    Install, Configure, Forget
  • 09-17-2007, 5:08 AM In reply to

    Re: How to set authentication with appcmd.exe or ServerManager

    Hehe.  While was working on the code side, I see Bernard posted the appcmd syntax, excellent.  I still would be curious via code how it would be done. 

    Steve Schofield
    Windows Server MVP - IIS
    http://weblogs.asp.net/steveschofield


    http://www.IISLogs.com
    Log archival solution
    Install, Configure, Forget
Page 1 of 1 (4 items)
Microsoft Communities