0 votes

Hi guys,

I trying to get working the powershell SDK for mail-enabling newly created contact. I use the SDK I found for this method but it doesn't seem to work well in my situation. The problem I have, is that the 4th object on the last line cannot be "empty" : "$user.MailEnable($alias, $externalMailAddress, $externalMailAddressType, $NULL)"

I have the error: Parameter must be a non empty string

I read about it and here is the information i got:
administrativeGroup - Specifies the ADS path of the Exchange administrative group for the e-mail address. When mail-enabling an object for Exchange 2007 and higher, the parameter must be set to NULL.

So I'm using a 2007 Exchange server, so I must set the last parameter to NULL.

I trying many thing and I'm out of idea. I also tried to output an echo of all the others parameters of my last line.
I got an alias and the externalMailAddress of the user I set, so the first part of the script is working very well.

Here is the powershell script :

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to user object
$userDN = "CN=My Contact,CN=Users,DC=domain,DC=com"  (I replaced this for the right ads path of my users)
$user = $admService.OpenObject("Adaxes://$userDN", $NULL, $NULL, 0)

# Mail-enable the contact
$alias = $user.Get("Name") # Alias
$externalMailAddress = $user.Get("mail") # External e-mail address
$externalMailAddressType = "SMTP" # External e-mail address type

$user.MailEnable($alias, $externalMailAddress, $externalMailAddressType, $NULL)
by (40 points)
0

Hello,

Are you launching the script as a part of a Business Rule, Custom Command or Scheduled Task or directly from the PowerShell console?

0

Directly from the powershell console. I was testing my script before I put it in a business rule. Does it need to be run directly on the Exchange server? Currently Adaxes services aren't install on the same server as our Exchange server. Thanks.

1 Answer

0 votes
by (216k points)

Hello,

No, you don't need to run the script from the Exchange server. Also, you don't need to install Adaxes on the Exchange Server. The only thing you need to do is to install Exchange 2007 Management Tools on the computer where Adaxes is installed. Without the tools, you'll get limited Exchange functionality that is only accessible via ADSI. With the Management Tools, you'll get complete Exchange functionality.

However, the reason for the error is not in the absence of Exchange Management tools. Can you post here a full output of the script?

By the way, why don't you use built-in Business Rule actions for this purpose? A Business Rule action called Establish e-mail address in Exchange can do exactly the same as the script that you are trying to test:

0

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to user object
$userDN = "CN=contact,OU=NAPA,OU=Contact,OU=Test,DC=domain,DC=local"
$user = $admService.OpenObject("Adaxes://$userDN", $NULL, $NULL, 0)

# Mail-enable the user
#$alias = "%samAccountName%" # Alias
$alias = $user.Get("Name") # Alias
$externalMailAddress = $user.Get("mail") # External e-mail address
$externalMailAddressType = "SMTP" # External e-mail address type

$user.MailEnable($alias, $externalMailAddress, $externalMailAddressType, $NULL)

GAC Version Location
--- ------- --------
True v2.0.50727 C:\Windows\assembly\GAC_MSIL\Softerra.Adaxes.Adsi\3.3.8906.0__43a637781bd9a3c2\Softerra.Adaxes.Adsi.dll
Exception lors de l'appel de « MailEnable » avec « 4 » argument(s) : « Parameter must be a non empty string.
Nom du paramètre : adsPath »
Au niveau de C:\Users\tester\Desktop\test2.ps1 : 16 Caractère : 17
+ $user.MailEnable <<<< ($alias, $externalMailAddress, $externalMailAddressType, $NULL)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException

You're right, the feature you talk about is exactly what I want but, I think it's only available in the lastest version of Adaxes if I'm right? We are using the version 2012.1 and this feature isn't there (I think so). Since i'm working for a very small business, I dont really need all the other bug fixes and new features right now. I would appreciate if we weren't obligated to buy the upgrade license for this little feature that seems to be accessible via powershell script. Thank you very much for your help it's very appreciated.

0

Hello,

We are using the version 2012.1

That explains everything :)

The Establish e-mail address in Exchange action appeared only in Adaxes 2013.1 that was dedicated to extended support of Exchange features. Adaxes 2012.1 didn't have such a Business Rule action.

As for the script, indeed you need to pass an Exchange Administrative Group as the 4th parameter. The thing is that starting from Exchange 2007, Microsoft dropped the most of support for Exchange Administrative Groups, leaving only one Administrative Group called Exchange Administrative Group (FYDIBOHF23SPDLT) by default. It is used mostly to support co-existance with older Exchange Servers. Before, Adaxes didn't take this into account and always required to pass an Administrative Group as the 4th parameter of the IAdmExchangeMailOps::MailEnable method regardless of Exchange version. Starting from Adaxes 2013.1, you don't need to pass it when Exchange 2007 or higher is used.

Since you have Adaxes 2012.1 installed, you'll need to pass the ADS Path of an Exchange Administrative Group to the script. However, since you are in an Exchange 2007 environment, the default Administrative Group Exchange Administrative Group (FYDIBOHF23SPDLT) can be simply hard-coded in the script. Here's a version of the script that should work with Adaxes 2012.1:

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$administrativeGroupPath = "Adaxes://CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=First Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=example,DC=com" # TODO: modify me

$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to user object
$userDN = "CN=My Contact,CN=Users,DC=domain,DC=com"  (I replaced this for the right ads path of my users)
$user = $admService.OpenObject("Adaxes://$userDN", $NULL, $NULL, 0)

# Mail-enable the contact
$alias = $user.Get("Name") # Alias
$externalMailAddress = $user.Get("mail") # External e-mail address
$externalMailAddressType = "SMTP" # External e-mail address type

$user.MailEnable($alias, $externalMailAddress, $externalMailAddressType, $administrativeGroupPath)

In the script, $administrativeGroupPath specifies the ADS Path of the default Administrative Group. Replace DC=example,DC=com with the Distinguished Name (DN) of your AD domain.

Also, if you are going to use the script in a Business Rule, Custom Command or Scheduled Task, it can be reduced to only 5 lines:

$administrativeGroupPath = "Adaxes://CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=First Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=example,DC=com" # TODO: modify me

$alias = $Context.TargetObject.Get("Name") # Alias
$externalMailAddress = $Context.TargetObject.Get("mail") # External e-mail address
$externalMailAddressType = "SMTP" # External e-mail address type
$Context.TargetObject.MailEnable("test", "test@gmail.com", "SMTP", $administrativeGroupPath)
0

It's working very well! Thanks you so much for the help to understand this issue. Your Support team is very nice, answer are fast and clear. Adaxe's support is one of the best I've ever seen.

0

Thank you for your good words, we really appreciate it! ;)

Related questions

0 votes
1 answer

Is there no "mail enable" action for contacts by default? I was able to create a button but I was suprised there wasn't one already built-in.

asked Aug 28, 2020 by ComputerHabit (790 points)
0 votes
1 answer

For some reason our Creating office 365 accounts has been failing to correctly mail-enable the users in our local exchange server - it builds it as a mail user ... ;domain&gt;.mail.onmicrosoft.com Am I missing something in my business rule setup?

asked Dec 9, 2014 by danftasc (440 points)
0 votes
1 answer

Hi, How to set up Business Rule to automatically mail-enable new groups?

asked Sep 16, 2011 by bambor (40 points)
0 votes
1 answer

What specific permission is needed in a security role to grant access to enable a user account?

asked Dec 7, 2023 by mightycabal (1.0k points)
0 votes
1 answer

After disable user, not user found or show when try to enable...i follow and try many way yet still not showing.. please help i;m using the ... -not-show-disabled-account https://www.adaxes.com/help/PreventUsersFromViewingTheStructure/#change-top-level-node

asked Oct 23, 2023 by kimtienh (20 points)
3,549 questions
3,240 answers
8,232 comments
547,814 users