トップ回答者
Local Systemで起動されているwindowsサービスでCreateProcessWithLogonWを使用すると、access denied

質問
-
以下のような構成で開発を行っています。c++プログラムは呼び出せているようですが、access deniedが返ってきてしまいます。
動作環境
Windows Server 2008 R2
C++プログラムは、VS 2008 Premium 64bit環境で、64bitアプリとしてビルド
Javaで作成したwindowsサービス
(Local Systemで起動。要件上、起動ユーザーは変更不可です。)
↓ Runtime.exec
C++で作成したプログラム(xxx.exe)
↓ CreateProcessWithLogonW でドメインユーザーを指定
powershellをドメインユーザーで起動
(PSconsoleオプションでExchangeのスナップインを指定し、-Commandで指定したDBディスマウント等のExchangeコマンドレットを実行)
↓
Access Denied エラーコード 5が返却される。
なお、windowsサービスからではなく、ローカルのAdministratorでログインして、
コマンドプロンプトからxxx.exeを実行したところ、正常にコマンド実行できました。
また、検証としてWindowsサービスをドメインユーザーで起動したところ、期待通りに動作しました。
(当然の結果とは思われますが。。)
windowsサービスを経由していることが問題なのか、Local SystemでCreateProcessWithLogonWを実行するには別途設定などが必要なのか、これだ!という情報にたどり着けずに困り果てております。
お心当たりのあるかた、どうかご助力頂けないでしょうか。よろしくお願い致します。
回答
-
CreateProcessWithLogonW()のドキュメントには、
Windows XP with SP2 and Windows Server 2003: You cannot call CreateProcessWithLogonW from a process that is running under the "LocalSystem" account, because the function uses the logon SID in the caller token, and the token for the "LocalSystem" account does not contain this SID. As an alternative, use the CreateProcessAsUser and LogonUser functions.
と書かれていますが、確認されていますか? 対象環境とは違いますが、現象は一致していますし、ここで提案されているCreateProcessAsUser()は試されたのでしょうか?
すべての返信
-
CreateProcessWithLogonW()のドキュメントには、
Windows XP with SP2 and Windows Server 2003: You cannot call CreateProcessWithLogonW from a process that is running under the "LocalSystem" account, because the function uses the logon SID in the caller token, and the token for the "LocalSystem" account does not contain this SID. As an alternative, use the CreateProcessAsUser and LogonUser functions.
と書かれていますが、確認されていますか? 対象環境とは違いますが、現象は一致していますし、ここで提案されているCreateProcessAsUser()は試されたのでしょうか?