This topic has 5 replies, 4 voices, and was last updated 6 years, 2 months ago by mn.saran.

  • Author
    Posts
  • #3797
     aivok
    Participant

    Hello,
    I need to connect OpenIDM 3.1 with Microsoft Exchange. As I read from documentation I can use Powershell connector for that purpose. I planned to use Powershell AD connector from openidm/samples/powershell2AD directory and modify the Powershell script files for Exchange management. Will that work or is there any better way to do that. Does it work with my existing AD connector? Is there any example scripts available for connecting to Exchange?

    Aivo

    #3799
     Anonymous
    Inactive

    Hello,
    Yes, this will work. Example configuration:

    AD connector

    ...
        "systemActions" : [
            {
                "scriptId" : "exchange2010_CreateMailbox",
                "actions" : [
                    {
                        "systemType" : ".*ActiveDirectoryConnector",
                        "actionType" : "PowerShell",
                        "actionFile" : "script/exchange2010_CreateMailbox.ps1"
                    }
                ]
            },
            {
                "scriptId" : "exchange2010_RenameMailbox",
                "actions" : [
                    {
                        "systemType" : ".*ActiveDirectoryConnector",
                        "actionType" : "PowerShell",
                        "actionFile" : "script/exchange2010_RenameMailbox.ps1"
                    }
                ]
            }
        ],
    ...

    PowerShell script – create
    As I can remember, I found similar script on this forum before.

    #Input parameters: $exchangeUserName, $exchangeUserPassword, $exchangeServer, $domainName, $samAccountName, $emailAlias, $exchangeDB
    try 
    {
    	$secPassword = ConvertTo-SecureString $exchangeUserPassword -AsPlainText -Force 
    	$Credentials = New-Object System.Management.Automation.PSCredential ($exchangeUserName, $secPassword)
    
    	$exchangeSession = New-PSSession -ErrorAction Stop -ConfigurationName Microsoft.Exchange -ConnectionUri http://$exchangeServer/PowerShell/ -Credential $Credentials -Authentication Kerberos
    	Import-PSSession $exchangeSession
    
    	Enable-Mailbox -Identity $domainName\$samAccountName -Alias $emailAlias -Database $exchangeDB
    	if ($Error.Count -gt 0) 
    	{
    		if ($exchangeSession) 
    		{
    			Remove-PSSession -ID $exchangeSession.ID
    		}
    		Write-Output $("ERROR: " + $error[0].ToString() + $error[0].InvocationInfo.PositionMessage)
    		Exit 1
    	}
    
    	if ($exchangeSession) 
    	{
    		Remove-PSSession -ID $exchangeSession.ID
    	}
    	Exit 0
    }
    catch 
    {
    	if ($exchangeSession) 
    	{
    		Remove-PSSession -ID $exchangeSession.ID
    	}
    	Write-Output $("ERROR: " + $error[0].ToString() + $error[0].InvocationInfo.PositionMessage)
    	Exit 1
    }
    #3802
     aivok
    Participant

    Thanks for the information. Is your example script about the case where I extend the current AD connector with Powershell scripts? I was thinking about creating completely separate connector so I have AD connector and Exchange connector and both connect to connector server separately.

    #3803
     Anonymous
    Inactive

    Correct, I have extended my current AD connector.
    You can create separate connector for Exchange only. But in this moment I don’t see a reason for this.

    #6298

    Hi,

    How do you call these scripts from post handlers?

    Version 2.1 openidm.action syntax doesn’t work.

    Thanks,
    Mukesh

    #11925
     mn.saran
    Participant

    do we know how to invoke these powershell scripts via postAction.like below? or via openidm.action?

    “action” : “CREATE”,
    “situation” : “ABSENT”,
    “postAction” : {
    “type” : “text/javascript”,
    “globals” : { },
    “file” : “script/idm-postcreate.js”
    }

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

©2022 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?