HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/win_iis.cpython-310.pyc
o

�N�g}�@s�dZdZdd�Zd,dd�Z		d-d
d�Zdd
�Z	d.dd�Zd,dd�Zd/dd�Zd0dd�Z	dd�Z
dd�Zd1dd�Zd1dd �Z
d!d"�Zd2d$d%�Zd2d&d'�Zd1d(d)�Zd1d*d+�ZdS)3z�
Microsoft IIS site management

This module provides the ability to add/remove websites and application pools
from Microsoft IIS.

.. versionadded:: 2016.3.0

Zwin_iiscCsdtvrtSdS)z<
    Load only on minions that have the win_iis module.
    �win_iis.create_site)Fz"win_iis module could not be loaded)�__salt__�__virtualname__�rr�G/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/win_iis.py�__virtual__sr��*�PcCsd�|||�dd��}|S)z[
    Combine the host header, IP address, and TCP port into bindingInformation format.
    z{}:{}:{}� r)�format�replace)�
hostheader�	ipaddress�port�retrrr�_get_binding_infosr�httpc	Cs�|iddd�}td�}||vrd|��|d<d|d<|Std	r1d
|��|d<d|d�|d<|Sd
|��|d<d|d�|d<td|||||||�|d<|S)a�
    Ensure the website has been deployed.

    .. note:

        This function only validates against the site name, and will return True even
        if the site already exists with a different configuration. It will not modify
        the configuration of an existing site.

    :param str name: The IIS site name.
    :param str sourcepath: The physical path of the IIS site.
    :param str apppool: The name of the IIS application pool.
    :param str hostheader: The host header of the binding.
    :param str ipaddress: The IP address of the binding.
    :param str port: The TCP port of the binding.
    :param str protocol: The application protocol of the binding.

    .. note:

        If an application pool is specified, and that application pool does not already exist,
        it will be created.

    Example of usage with only the required arguments. This will default to using the default application pool
    assigned by IIS:

    .. code-block:: yaml

        site0-deployed:
            win_iis.deployed:
                - name: site0
                - sourcepath: C:\inetpub\site0

    Example of usage specifying all available arguments:

    .. code-block:: yaml

        site0-deployed:
            win_iis.deployed:
                - name: site0
                - sourcepath: C:\inetpub\site0
                - apppool: site0
                - hostheader: site0.local
                - ipaddress: '*'
                - port: 443
                - protocol: https
    Nr��name�changes�result�comment�win_iis.list_siteszSite already present: rTr�testzSite will be created: ��old�newrzCreated site: r�r�__opts__)	r�
sourcepath�apppoolr
rr�protocolr�
current_sitesrrr�deployed!s 1

���r#cC�|iddd�}td�}||vrd|��|d<d|d<|Std	r1d
|��|d<|dd�|d<|Sd
|��|d<|dd�|d<td|�|d<|S)z�
    Delete a website from IIS.

    :param str name: The IIS site name.

    Usage:

    .. code-block:: yaml

        defaultwebsite-remove:
            win_iis.remove_site:
                - name: Default Web Site
    NrrrzSite has already been removed: rTrrzSite will be removed: rrzRemoved site: zwin_iis.remove_siter)rrr"rrr�remove_sitees
��r%�c
Cs�|iddd�}t|||�}td|�}	||	vr$d|��|d<d|d<|Std	r8d
|��|d<d|d�|d<|Sd
|��|d<d|d�|d<td||||||�|d<|S)a�
    Create an IIS binding.

    .. note:

        This function only validates against the binding ipaddress:port:hostheader combination,
        and will return True even if the binding already exists with a different configuration.
        It will not modify the configuration of an existing binding.

    :param str site: The IIS site name.
    :param str hostheader: The host header of the binding.
    :param str ipaddress: The IP address of the binding.
    :param str port: The TCP port of the binding.
    :param str protocol: The application protocol of the binding.
    :param str sslflags: The flags representing certificate type and storage of the binding.

    Example of usage with only the required arguments:

    .. code-block:: yaml

        site0-https-binding:
            win_iis.create_binding:
                - site: site0

    Example of usage specifying all available arguments:

    .. code-block:: yaml

        site0-https-binding:
            win_iis.create_binding:
                - site: site0
                - hostheader: site0.local
                - ipaddress: '*'
                - port: 443
                - protocol: https
                - sslflags: 0
    rN�rrrr�win_iis.list_bindingszBinding already present: rTrrzBinding will be created: rrzCreated binding: zwin_iis.create_binding�rrr)
r�siter
rrr!�sslflagsr�binding_info�current_bindingsrrr�create_binding�s"(
���r.cCs�|iddd�}t|||�}td|�}||vr$d|��|d<d|d<|Std	r8d
|��|d<|dd�|d<|Sd
|��|d<|dd�|d<td||||�|d<|S)a�
    Remove an IIS binding.

    :param str site: The IIS site name.
    :param str hostheader: The host header of the binding.
    :param str ipaddress: The IP address of the binding.
    :param str port: The TCP port of the binding.

    Example of usage with only the required arguments:

    .. code-block:: yaml

        site0-https-binding-remove:
            win_iis.remove_binding:
                - site: site0

    Example of usage specifying all available arguments:

    .. code-block:: yaml

        site0-https-binding-remove:
            win_iis.remove_binding:
                - site: site0
                - hostheader: site0.local
                - ipaddress: '*'
                - port: 443
    rNr'r(z"Binding has already been removed: rTrrzBinding will be removed: rrzRemoved binding: zwin_iis.remove_bindingr))rr*r
rrrr,r-rrr�remove_binding�s"
���r/�c
Cs�|iddd�}t|||�}td|�}||vr;||d}	||	kr.d|��|d<d|d	<|Sd
�|	�|d<d|d	<|StdrOd
|��|d<d|d�|d<|Sd|��|d<d|d�|d<td||||||�|d	<|S)a�
    Assign a certificate to an IIS binding.

    .. note:

        The web binding that the certificate is being assigned to must already exist.

    :param str name: The thumbprint of the certificate.
    :param str site: The IIS site name.
    :param str hostheader: The host header of the binding.
    :param str ipaddress: The IP address of the binding.
    :param str port: The TCP port of the binding.
    :param str sslflags: Flags representing certificate type and certificate storage of the binding.

    Example of usage with only the required arguments:

    .. code-block:: yaml

        site0-cert-binding:
            win_iis.create_cert_binding:
                - name: 9988776655443322111000AAABBBCCCDDDEEEFFF
                - site: site0

    Example of usage specifying all available arguments:

    .. code-block:: yaml

        site0-cert-binding:
            win_iis.create_cert_binding:
                - name: 9988776655443322111000AAABBBCCCDDDEEEFFF
                - site: site0
                - hostheader: site0.local
                - ipaddress: 192.168.1.199
                - port: 443
                - sslflags: 1

    .. versionadded:: 2016.11.0
    rNr'�win_iis.list_cert_bindings�certificatehashz%Certificate binding already present: rTrzCCertificate binding already present with a different thumbprint: {}Frz%Certificate binding will be created: rrzCreated certificate binding: zwin_iis.create_cert_binding)rrrr)
rr*r
rrr+rr,�current_cert_bindings�current_namerrr�create_cert_binding�s0'�
���r5c	Cs�|iddd�}t|||�}td|�}||vr$d|��|d<d|d<|Std	r8d
|��|d<|dd�|d<|S||d
}||kr\d|��|d<|dd�|d<td|||||�|d<|S)aU
    Remove a certificate from an IIS binding.

    .. note:

        This function only removes the certificate from the web binding. It does
        not remove the web binding itself.

    :param str name: The thumbprint of the certificate.
    :param str site: The IIS site name.
    :param str hostheader: The host header of the binding.
    :param str ipaddress: The IP address of the binding.
    :param str port: The TCP port of the binding.

    Example of usage with only the required arguments:

    .. code-block:: yaml

        site0-cert-binding-remove:
            win_iis.remove_cert_binding:
                - name: 9988776655443322111000AAABBBCCCDDDEEEFFF
                - site: site0

    Example of usage specifying all available arguments:

    .. code-block:: yaml

        site0-cert-binding-remove:
            win_iis.remove_cert_binding:
                - name: 9988776655443322111000AAABBBCCCDDDEEEFFF
                - site: site0
                - hostheader: site0.local
                - ipaddress: 192.168.1.199
                - port: 443

    .. versionadded:: 2016.11.0
    rNr'r1z.Certificate binding has already been removed: rTrrz%Certificate binding will be removed: rrr2zRemoved certificate binding: zwin_iis.remove_cert_bindingr))	rr*r
rrrr,r3r4rrr�remove_cert_binding5s&&
�
�
�r6cCs�|iddd�}td�}||vrd|��|d<d|d<|Std	r1d
|��|d<d|d�|d<|Sd
|��|d<d|d�|d<td|�|d<|S)a�
    Create an IIS application pool.

    .. note:

        This function only validates against the application pool name, and will return
        True even if the application pool already exists with a different configuration.
        It will not modify the configuration of an existing application pool.

    :param str name: The name of the IIS application pool.

    Usage:

    .. code-block:: yaml

        site0-apppool:
            win_iis.create_apppool:
                - name: site0
    Nrr�win_iis.list_apppoolsz"Application pool already present: rTrrz"Application pool will be created: rrzCreated application pool: zwin_iis.create_apppoolr�rrZcurrent_apppoolsrrr�create_apppoolrs
��r9cCr$)z�
    Remove an IIS application pool.

    :param str name: The name of the IIS application pool.

    Usage:

    .. code-block:: yaml

        defaultapppool-remove:
            win_iis.remove_apppool:
                - name: DefaultAppPool
    Nrrr7z+Application pool has already been removed: rTrrz"Application pool will be removed: rrzRemoved application pool: zwin_iis.remove_apppoolrr8rrr�remove_apppool�s
��r:Nc	Cs�dddddd�}|iddd	�}|sd
|d<d|d
<|Siid�}td|||��d�}|D];}|dkrA|||vrA|||||<t||�t||�krh|dkr[ddd�|d|<q-||||d�|d|<q-|dswd|d<d|d
<|Stdr�d|d<|d|d<|Std|||d�td|||��d�}|D]?}t||�t||�kr�|dkr�ddd�|d|<n
||||d�|d|<|d�|d�q�|dkr�ddd�|d|<q�|dr�d|d<||d<d|d
<|Sd|d<|d|d<d|d
<|S)a�
    Set the value of the setting for an IIS container.

    :param str name: The name of the IIS container.
    :param str container: The type of IIS container. The container types are:
        AppPools, Sites, SslBindings
    :param str settings: A dictionary of the setting names and their values.
        Example of usage for the ``AppPools`` container:

    .. code-block:: yaml

        site0-apppool-setting:
            win_iis.container_setting:
                - name: site0
                - container: AppPools
                - settings:
                    managedPipelineMode: Integrated
                    processModel.maxProcesses: 1
                    processModel.userName: TestUser
                    processModel.password: TestPassword
                    processModel.identityType: SpecificUser

    Example of usage for the ``Sites`` container:

    .. code-block:: yaml

        site0-site-setting:
            win_iis.container_setting:
                - name: site0
                - container: Sites
                - settings:
                    logFile.logFormat: W3C
                    logFile.period: Daily
                    limits.maxUrlSegments: 32
    ZLocalSystemZLocalServiceZNetworkServiceZSpecificUserZApplicationPoolIdentity)r&����rNr'�No settings to change provided.rTr�r�failureszwin_iis.get_container_setting)r�	container�settingszprocessModel.identityTypezprocessModel.passwordzXXX-REDACTED-XXXrr�-Settings already contain the provided values.r�Settings will be changed.zwin_iis.set_container_settingrA�Some settings failed to change.F�,Set settings to contain the provided values.�r�keys�strr�pop)	rrBrCZidentityType_map2stringr�ret_settings�current_settings�setting�new_settingsrrr�container_setting�s�&��
�����
������rPcCs�|iddd�}td|�}||vrd|��|d<d|d<|Std	r2d
|��|d<d|d�|d<|Sd
|��|d<d|d�|d<td||||�|d<|S)a�
    Create an IIS application.

    .. note:

        This function only validates against the application name, and will return True
        even if the application already exists with a different configuration. It will not
        modify the configuration of an existing application.

    :param str name: The IIS application.
    :param str site: The IIS site name.
    :param str sourcepath: The physical path.
    :param str apppool: The name of the IIS application pool.

    Example of usage with only the required arguments:

    .. code-block:: yaml

        site0-v1-app:
            win_iis.create_app:
                - name: v1
                - site: site0
                - sourcepath: C:\inetpub\site0\v1

    Example of usage specifying all available arguments:

    .. code-block:: yaml

        site0-v1-app:
            win_iis.create_app:
                - name: v1
                - site: site0
                - sourcepath: C:\inetpub\site0\v1
                - apppool: site0
    rNr'�win_iis.list_appszApplication already present: rTrrzApplication will be created: rrzCreated application: zwin_iis.create_appr)rr*rr r�current_appsrrr�
create_app7s$��rScCs�|iddd�}td|�}||vrd|��|d<d|d<|Std	r2d
|��|d<|dd�|d<|Sd
|��|d<|dd�|d<td||�|d<|S)a
    Remove an IIS application.

    :param str name: The application name.
    :param str site: The IIS site name.

    Usage:

    .. code-block:: yaml

        site0-v1-app-remove:
            win_iis.remove_app:
                - name: v1
                - site: site0
    rNr'rQz&Application has already been removed: rTrrzApplication will be removed: rrzRemoved application: zwin_iis.remove_appr)rr*rrRrrr�
remove_appls��rT�/cCs�|iddd�}td||�}||vrd|��|d<d|d<|Std	r3d
|��|d<d|d�|d<|Sd
|��|d<d|d�|d<td||||�|d<|S)a�
    Create an IIS virtual directory.

    .. note:

        This function only validates against the virtual directory name, and will return
        True even if the virtual directory already exists with a different configuration.
        It will not modify the configuration of an existing virtual directory.

    :param str name: The virtual directory name.
    :param str site: The IIS site name.
    :param str sourcepath: The physical path.
    :param str app: The IIS application.

    Example of usage with only the required arguments:

    .. code-block:: yaml

        site0-foo-vdir:
            win_iis.create_vdir:
                - name: foo
                - site: site0
                - sourcepath: C:\inetpub\vdirs\foo

    Example of usage specifying all available arguments:

    .. code-block:: yaml

        site0-foo-vdir:
            win_iis.create_vdir:
                - name: foo
                - site: site0
                - sourcepath: C:\inetpub\vdirs\foo
                - app: v1
    rNr'�win_iis.list_vdirsz#Virtual directory already present: rTrrz#Virtual directory will be created: rrzCreated virtual directory: zwin_iis.create_vdirr)rr*r�appr�
current_vdirsrrr�create_vdir�s$	��rYcCs�|iddd�}td||�}||vrd|��|d<d|d<|Std	r3d
|��|d<|dd�|d<|Sd
|��|d<|dd�|d<td|||�|d<|S)ac
    Remove an IIS virtual directory.

    :param str name: The virtual directory name.
    :param str site: The IIS site name.
    :param str app: The IIS application.

    Example of usage with only the required arguments:

    .. code-block:: yaml

        site0-foo-vdir-remove:
            win_iis.remove_vdir:
                - name: foo
                - site: site0

    Example of usage specifying all available arguments:

    .. code-block:: yaml

        site0-foo-vdir-remove:
            win_iis.remove_vdir:
                - name: foo
                - site: site0
                - app: v1
    rNr'rVz,Virtual directory has already been removed: rTrrz#Virtual directory will be removed: rrzRemoved virtual directory: zwin_iis.remove_vdirr)rr*rWrrXrrr�remove_vdir�s	��rZcCsr|iddd�}|sd|d<d|d<|Siid�}td	|||��d
�}|D]}t||�t||�kr@||||d�|d|<q%|dsOd
|d<d|d<|Stdr]d|d<||d<|Std|||d
�td	|||��d
�}|D]#}t||�t||�kr�||||d�|d|<|d�|d�qs|dr�d|d<||d<d|d<|Sd|d<|d|d<d|d<|S)a�
    .. versionadded:: 2017.7.0

    Set the value of the setting for an IIS web application.

    .. note::
        This function only configures existing app. Params are case sensitive.

    :param str name: The IIS application.
    :param str site: The IIS site name.
    :param str settings: A dictionary of the setting names and their values.

    Available settings:

    - ``physicalPath`` - The physical path of the webapp
    - ``applicationPool`` - The application pool for the webapp
    - ``userName`` "connectAs" user
    - ``password`` "connectAs" password for user

    :rtype: bool

    Example of usage:

    .. code-block:: yaml

        site0-webapp-setting:
            win_iis.set_app:
                - name: app0
                - site: Default Web Site
                - settings:
                    userName: domain\\user
                    password: pass
                    physicalPath: c:\inetpub\wwwroot
                    applicationPool: appPool0
    rNr'r?rTrr@zwin_iis.get_webapp_settings)rr*rCrrrDrrEzwin_iis.set_webapp_settingsrArFFrGrH)rr*rCrrLrMrNrOrrr�set_app�sZ&�
���
����r[cCs�|iddd�}|sd|d<d|d<|Siid�}t�}|��D]\}}|��D]
\}}|�|||d	��q'qtd
||d�}	t|�D]j\}
}|d�d
�ddk}t|	�|
krmi||
dd�|d|dd
|d<qB|r�ttt|d��ttt|	|
d��ks�|s�t	|d�t	|	|
d�kr�|	|
d||
dd�|d|dd
|d<qB|ds�d|d<d|d<|St
dr�d|d<||d<|Std||d�}
td
||d�}t|�D]W\}
}|d�d
�ddk}|r�|d||
dk�s|�s4t	|d�t	||
d�k�r4|	|
d||
dd�|d|dd
|d<|d�|dd
|dd�q�|d�rHd|d<||d<d|d<|Sd|d<|d|d<|
|d<|S)aG
    Set the value of webconfiguration settings.

    :param str name: The name of the IIS PSPath containing the settings.
        Possible PSPaths are :
        MACHINE, MACHINE/WEBROOT, IIS:\, IIS:\Sites\sitename, ...
    :param dict settings: Dictionaries of dictionaries.
        You can match a specific item in a collection with this syntax inside a key:
        'Collection[{name: site0}].logFile.directory'

    Example of usage for the ``MACHINE/WEBROOT`` PSPath:

    .. code-block:: yaml

        MACHINE-WEBROOT-level-security:
          win_iis.webconfiguration_settings:
            - name: 'MACHINE/WEBROOT'
            - settings:
                system.web/authentication/forms:
                  requireSSL: True
                  protection: "All"
                  credentials.passwordFormat: "SHA1"
                system.web/httpCookies:
                  httpOnlyCookies: True

    Example of usage for the ``IIS:\Sites\site0`` PSPath:

    .. code-block:: yaml

        site0-IIS-Sites-level-security:
          win_iis.webconfiguration_settings:
            - name: 'IIS:\Sites\site0'
            - settings:
                system.webServer/httpErrors:
                  errorMode: "DetailedLocalOnly"
                system.webServer/security/requestFiltering:
                  allowDoubleEscaping: False
                  verbs.Collection:
                    - verb: TRACE
                      allowed: False
                  fileExtensions.allowUnlisted: False

    Example of usage for the ``IIS:\`` PSPath with a collection matching:

    .. code-block:: yaml

        site0-IIS-level-security:
          win_iis.webconfiguration_settings:
            - name: 'IIS:\'
            - settings:
                system.applicationHost/sites:
                  'Collection[{name: site0}].logFile.directory': 'C:\logs\iis\site0'

    rNr'r?rTrr@)�filterr�valuez%win_iis.get_webconfiguration_settings)rrCr�.����
Collectionr]rrr\rDrrEz%win_iis.set_webconfiguration_settingsrArFFrG)�list�items�appendr�	enumerate�split�len�map�dictrJr�get)rrCrrLZ
settings_listr\Zfilter_settingsZsetting_namer]Zcurrent_settings_list�idxrNZ
is_collection�successZnew_settings_listrrr�webconfiguration_settingsMs�8�
���
 ����

�����

� �
�rl)rrr	)rrrr	r)rrr	rr&)rrr0r&)rrr0)N)rU)�__doc__rrrr#r%r.r/r5r6r9r:rPrSrTrYrZr[rlrrrr�<module>s*
	

�D!
�
<
0
D=&
!
~5
!
6
-]