Omgeving :
Webplatform : Windows 2008R2 + IIS7.5 + PHP v5.2.14
Exchange : Windows 2008R2 + Exchange 2010
Authentication : AD via Windows2008R2
Via een PHP Script wil ik powershell aanroepen. Hieruit de RemoteExchange.ps1 file inporteren , een auto connect naar de exchange server maken en de mailboxen queryen (en later ook mailboxen + archieven aanmaken)
Er zijn een aantal zaken waar ik tegen aanloop (voornamelijk rechten problemen waar waarschijnlijk wel een oplossing voor te vinden is) maar nu loop ik tegen iets op waar ik even niet uit kom.
Het volgende script werkt prima vanuit een .bat file
Vanuit PHP (ongeacht de rechten van de user voor de application pool (local , domain / domain-admin) krijg ik het niet voor elkaar.
output via PHP -->
Ik heb hier uit geconcludeerd dat er vanuit een door PHP aangeroepen Shell_exec er blijkbaar geen leesrechten zijn in de registry?
Dit gaat al fout -->
Een test.ps1 file met daarin :
geeft via PHP
Momenteel is de application pool waar dit script draait gekoppeld aan een local-admin gebruiker. De rechten op deze HKLM entry zijn read-able voor alle gebruikers.
Iemand een idee? Het lijkt er op dat er in IIS nog iets niet goed gaat.
PS : Gelieve geen discussie over waarom PHP gebruikt is voor deze aanpak. Dit is een gegeven.
Webplatform : Windows 2008R2 + IIS7.5 + PHP v5.2.14
Exchange : Windows 2008R2 + Exchange 2010
Authentication : AD via Windows2008R2
Via een PHP Script wil ik powershell aanroepen. Hieruit de RemoteExchange.ps1 file inporteren , een auto connect naar de exchange server maken en de mailboxen queryen (en later ook mailboxen + archieven aanmaken)
Er zijn een aantal zaken waar ik tegen aanloop (voornamelijk rechten problemen waar waarschijnlijk wel een oplossing voor te vinden is) maar nu loop ik tegen iets op waar ik even niet uit kom.
Het volgende script werkt prima vanuit een .bat file
code:
1
| powershell.exe -noprofile -noexit -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto ;Get-Mailbox" |
Vanuit PHP (ongeacht de rechten van de user voor de application pool (local , domain / domain-admin) krijg ik het niet voor elkaar.
output via PHP -->
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
| Exception calling "TryLoadExchangeTypes" with "2" argument(s): "Unable to determine the installed file version from the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ExchangeServer\v14\Setup'." At C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchangeCustom.ps1:75 char:92 + $typeLoadResult = [Microsoft.Exchange.Configuration.Tasks.TaskHelper]::TryLoadExchangeTypes <<<< ($ManagementPath, $t ypeListToCheck) + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException The Exchange types file wasn't loaded because not all of the required files could be found. Update-TypeData : The following error occurred while loading the extended type data file: Microsoft.PowerShell, C:\Program Files\Microsoft\Exchange Server\V14\bin\Exchange.partial.Types.ps1xml(80) : Error in t ype "Deserialized.Microsoft.Exchange.Management.SystemConfigurationTasks.ExchangeCertificate": Cannot convert note "Tar getTypeForDeserialization":"Cannot convert the "Microsoft.Exchange.Management.SystemConfigurationTasks.ExchangeCertific ate" value of type "System.String" to type "System.Type".". At C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchangeCustom.ps1:104 char:16 + Update-TypeData <<<< -PrependPath $partialTypeFile + CategoryInfo : InvalidOperation: (:) [Update-TypeData], RuntimeException + FullyQualifiedErrorId : TypesXmlUpdateException,Microsoft.PowerShell.Commands.UpdateTypeDataCommand Welcome to the Exchange Management Shell! Full list of cmdlets: Get-Command Only Exchange cmdlets: Get-ExCommand Cmdlets that match a specific string: Help ** Get general help: Help Get help for a cmdlet: Help or -? Show quick reference guide: QuickRef Exchange team blog: Get-ExBlog Show full output for a command: | Format-List Tip of the day #20: Before you remove an object by using the Remove verb, use the WhatIf parameter to verify the results are what you expect. The term 'Get-Mailbox' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:123 + . 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchangeCustom.ps1' Connect-ExchangeServer -auto ;Get-Ma ilbox <<<< ; + CategoryInfo : ObjectNotFound: (Get-Mailbox:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException |
Ik heb hier uit geconcludeerd dat er vanuit een door PHP aangeroepen Shell_exec er blijkbaar geen leesrechten zijn in de registry?
Dit gaat al fout -->
Een test.ps1 file met daarin :
code:
1
| $global:exbin = (get-itemproperty HKLM:\SOFTWARE\Microsoft\ExchangeServer\v14\Setup).MsiInstallPath + "bin\" |
geeft via PHP
code:
1
2
3
4
5
6
7
8
9
| Get-ItemProperty : Cannot find path 'HKLM:\SOFTWARE\Microsoft\ExchangeServer\v1 4\Setup' because it does not exist. At C:\inetpub\wwwroot\tools\powershell\test.ps1:1 char:34 + $global:exbin = (get-itemproperty <<<< HKLM:\SOFTWARE\Microsoft\ExchangeServ er\v14\Setup).MsiInstallPath + "bin\" + CategoryInfo : ObjectNotFound: (HKLM:\SOFTWARE\...erver\v14\Set up:String) [Get-ItemProperty], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetIt emPropertyCommand |
Momenteel is de application pool waar dit script draait gekoppeld aan een local-admin gebruiker. De rechten op deze HKLM entry zijn read-able voor alle gebruikers.
Iemand een idee? Het lijkt er op dat er in IIS nog iets niet goed gaat.
PS : Gelieve geen discussie over waarom PHP gebruikt is voor deze aanpak. Dit is een gegeven.