0 votes

Hello

I need to read/store a password in the Adaxes System.

I have created this script:

Import-Module Adaxes

$exchangeServer = "exchangeserver.CH" # TODO: modify me

# Get the name of the domain of the master account
#$linkedDomainName = $Context.GetObjectDomain("%distinguishedName%")
$linkedDomainName = "linked.ch"

# Get domain controlers in the domain of the master account
$linkedDomainControler = "dclinked.linked.ch"

# Get credentials for the resource domain
$exchangeAdminName = $Context.RunAs.UserName
$exchangeAdminPassword = ConvertTo-SecureString -AsPlainText -Force -String $Context.RunAs.Password

$credential = New-Object -TypeName System.Management.Automation.PSCredential($exchangeAdminName, $exchangeAdminPassword)

# Connect to Exchange Server in the resource domain and create linked mailbox
$session = New-PSSession –ConfigurationName Microsoft.Exchange –ConnectionUri "http://$exchangeServer/PowerShell/" -Credential $credential
Import-PSSession $session -AllowClobber -DisableNameChecking

    $Context.LogMessage($linkedDomainControler, "Information")
    try
    {

            $linkedReadUser = "linked\adaxesread"
            $linkedReadPassword = ConvertTo-SecureString -AsPlainText -Force -String "supersecurepassword."

            $credentialExploit = New-Object -TypeName System.Management.Automation.PSCredential($linkedReadUser, $linkedReadPassword)

           set-User -Identity '%sAMAccountName%' -LinkedDomainController $linkedDomainControler -LinkedMasterAccount "linked\%username%" -UserPrincipalName "%username%@linked.ch" -LinkedCredential $credentialExploit
    }
    catch
    {
        $Context.LogMessage($linkedDomainControler.DNSHostName + ":" + $_.Exception.Message, "Warning")
        continue
    }

Remove-PSSession $session

The problem is the line
$linkedReadPassword = ConvertTo-SecureString -AsPlainText -Force -String "supersecurepassword."

I prefer that I can store the password secure in Adaxes and read this information for the script.
Like in this line
$exchangeAdminPassword = ConvertTo-SecureString -AsPlainText -Force -String $Context.RunAs.Password

My script do only set the LinkedMasterAccount in the Resource Forest to activate a Linked mailbox in Exchange.
I must run the script unter a user from the Resource Forest who have access to Exchange.
The command set-user need a user/pwd from the Linked Domain as parameter.

Thank you for your help.

Regards
Gustav

by (40 points)

Please log in or register to answer this question.

Related questions

0 votes
1 answer

Hello, I'm trying to run a powershell script after password reset in order to create a record of the new password in a mysql database. Here is the script I'm using: ... 26/2014 3:53:17 PM',ip='Adaxes',modbyuser='ryan_breneman@domain.org' Thanks for your help!

asked Feb 26, 2014 by ryan_breneman (920 points)
0 votes
1 answer

The Adaxes Script Repository used to have two related scripts "Get custom value stored in Adaxes configuration" and "Store data in Adaxes configuration". These scripts ... /https://www.adaxes.com/script-repository/store-data-in-adaxes-configuration-s430.htm

asked Sep 1, 2023 by Carl Bruinsma (120 points)
0 votes
1 answer

Hello, We need to be able to put the ticket number into the custom command 'Deprovision'. Action -> Modify the user: set description to [ ... deprovision process set adminDescription with ticket number run Custom Command 'Deprovision' regards Helmut

asked Oct 14, 2020 by a423385 (510 points)
0 votes
1 answer

We are currently working on automating the property patterns. So far we were able to add all the needed properties to a Property Pattern via PowerShell script apart from the ... 't quite match the "should be" screenshot. Any help would be much appriciated.

asked Apr 30, 2020 by MichaelM (60 points)
0 votes
1 answer

Is there any business logic in ADAxess to let it handle basic load balancing of users between different stores ? /Kaj

asked Sep 7, 2017 by KajLehtinen (650 points)
3,434 questions
3,130 answers
7,984 comments
546,294 users