0 votes

In our environment we have to manage multiple objects for each user.
- Primary Account on domain A/B
- Mailbox account on domain C/D
- GALSync contact on domain D/C (resource domain opposite mailbox)

In order to ensure that changes on the primary account are applied to the correct object on each domain, we've created some custom attributes to store the SID/GUID of each object on it's associated objects.

masterAccountDomain - domain name of the primary user account
msExchMasterAccountSid - SID of the primary user account
resourceAccountDomain - domain name of the mailbox user account
resourceAccountSid - SID of the mailbox user account
gALSyncContactDomain - domain name of the GALSync contact
gALSyncContactGUID - GUID of the GALSync contact

We are beginning to work with these attributes and I've run into difficulty dealing with the gALSyncContactGUID. The issue is, when the attribute is retrieved the type returned is a decimal array. I need to get the GUID in string format to work with it.

The current task I am working on is copying a manager that it set on the primary user account to the mailbox account and to the GALSync contact. I'm binding to the manager's primary account and retrieving the custom attributes as follows.

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

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

$managerUsername = "%adm-ManagerUserName%"
$managerDN = (Get-AdmUser -Identity $managerUsername).distinguishedName
$manager = $admService.OpenObject("Adaxes://$managerDN", $NULL, $NULL, 0)

$managerMailboxDomain = $manager.Get("resourceAccountDomain")
$managerMailboxSID = New-Object System.Security.Principal.SecurityIdentifier($manager.Get("resourceAccountSID"), 0)
$managerMailboxSID = $managerMailboxSID.ToString()
$managerMailboxDN = (Get-AdmUser $managerMailboxSID -Server $manager.Get("resourceAccountDomain")).distinguishedName

$managerContactDomain = $manager.Get("gALSyncContactDomain")
$managerContactGUID = New-Object "System.Guid" (,$manager.Get("gALSyncContactGUID")) <--- Error here
$managerContactGUID = $managerContactGUID.ToString()
$managerContactDN = (Get-AdmObject $managerContactGUID -Server $managerContactDomain).distinguishedName

The problem I'm having is the gALSyncContactGUID property is being retrieved as a decimal array instead of the hex, so the conversion to the guid type fails. I just can't seem to get this into string format. Any insight would be appreciated.

by (290 points)

1 Answer

0 votes
by (290 points)

Looks like I've got this figured out... that always happens right after I post.

# Convert GUID

$managerGUID = $manager.Get("gALSyncContactGUID")
$managerGUID = [System.Text.Encoding]::ASCII.GetString($managerGUID)

Related questions

0 votes
0 answers

Ever since upgrading to 3.16.21906.0 the script here no longer works: https://www.adaxes.com/script-repository/move-mailbox-tofrom-microsoft-365-s579.htm Not sure what the issue is as I can't find any errors in the log.

asked Nov 16, 2023 by curtisa (290 points)
0 votes
1 answer

In our environment we are running Exchange 2010 on a resource forest. Users have accounts on a primary forest and mailbox accounts on the resource forest and the two ... resourceAccountSID attribute? This is in a powershell action being run by a business rule.

asked May 9, 2014 by dtb147 (290 points)
0 votes
1 answer

Hi, I'm working on my "account lifecycle" review processes and have a new area that I'm starting to think about. When staff who are also managers (of both users ... use! I appreciate there are some complex questions in here, so don't prioritise! Many Thanks

asked May 30, 2013 by firegoblin (1.6k points)
0 votes
1 answer

We recently migrated some accounts to a new Forest that is part of the same Tenant. After migration of Shared mailboxes I get GUIDs for delegates. The image shows 3 ... migration as expected. So far the GUID doesn't appear to match the migrated account.

asked Jul 6, 2021 by ComputerHabit (790 points)
3,549 questions
3,240 answers
8,232 comments
547,815 users