pywinrmモジュールを使用しているPythonコードで奇妙な問題が発生しました。 少し説明しましょう。PywinrmとActive Directory PowerShellコマンドレット
import winrm
"""Create security group"""
s = winrm.Session('https://servername:5986/wsman',
auth=(None, None), transport='kerberos',
server_cert_validation='ignore')
name = "test"
path = "OU=Security Groups,DC=test,DC=org"
ps_command = 'New-ADGroup -Name "{0}"
-GroupScope Universal
-GroupCategory Security
-Path "{1}" -Server ldap.test.org'.format(name, path)
r = s.run_ps(ps_command)
if r.status_code == 0 :
print(r.std_out.decode('UTF-8'))
else:
print(r.std_err('UTF-8'))
この1つは、グループ作成のコマンドを起動するWindowsサーバ(ないDC)のHTTPSリスナーに接続します:私は、私は次のPythonスクリプトを起動するLinuxサーバを持っています。
Windowsサーバー上で直接AD cmdletを起動すると、完全に動作し、セキュリティグループがAD内に作成されます。しかし、スクリプトを使用して、私は次の応答があります
$ python3 test_winrm.py
New-ADGroup : Unable to contact the server. This may be because this server does not exist, it is currently down,
or it does not have the Active Directory Web Services running.
At line:1 char:1
+ New-ADGroup -Name "test" -GroupScope Universal -GroupCategory Security
-Path "O ...
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
+ CategoryInfo : ResourceUnavailable: (:) [New-ADGroup], ADServer
DownException
+ FullyQualifiedErrorId : ActiveDirectoryServer:0,Microsoft.ActiveDirector
y.Management.Commands.NewADGroup
私は気づくこともしたいしている私は基本的なもので、現在のPowerShellコマンドを置き換える場合(たとえば、Windowsサーバ上のフォルダの作成)、それを働く
RSATがインストールされていても、Windowsサーバー上ではローカルに動作しますが、ADコマンドレットでは動作しません。
ありがとうございました。
[ダブルホップ](https://blogs.technet.microsoft.com/ashleymcglone/2016/08/30/powershell-remoting-kerberos-double-hop-solved-securely/)のような問題が発生します。 – BenH