How to set manager attribute in Active Directory

I'm trying to update the AD manager field using PS. We we're given a CSV file from HR with everyone's manager info. This is PS script.

Import-Module ActiveDirectory
$Users = Import-Csv "C:\Users\Administrator.APC-SERVICES\Desktop\mngimport\Managers1.csv"
ForEach ($User in $User)
{
$ADUser = Get-ADUser -Filter "displayname -eq '$($User.ProfessionalFullName)'"
$manager = (Get-ADUser -Filter "displayname -eq '$($User.'ManagerFullName')'").distinguishedname

if ($ADUser -and $manager) {
Set-ADUser -Identity $ADUser -Replace @{manager = $manager }
}
}

Nothing happens after running this. I keep checking the AD Users and the Manager attribute does not update. What am i missing?

CSV format:
ProfessionalFullName,ManagerFullName
Greg Brown,Jay Smith
Jesus Lopez ,Jay Smith
Stephen Jones,Jay Smith
Scott Williams ,Roy Miller
Jason Davis,Roy Miller

Starting with version 5.0.7.9 and above of AD Bulk Users you can set a users manager value using the managers username, distinguishedName or the managers employeeID.

Internally in Active Directory a users Manager (seen on the Organization tab) is stored using the managers distinguishedName, although you are shown the managers cn value.

How to set manager attribute in Active Directory

When setting manager attribute we  need to provide the distinguishedName or the manager, for example:

CN=James Blunt,OU=Managers,DC=Domain,DC=Com

With AD Bulk Users version 5.0.7.9 and later the program can *search Active Directory for the manager’s distinguishedName if your provide the managers sAMAccountName (username of the manger) or the manager’s employeeID value.

Below are three example CSV files that would set a users manager value.

Using the managers sAMAccountName (username)

sAMAccountName,Modify,manager
pjones,True,jblunt

Using the managers employeeID

sAMAccountName,Modify,manager
pjones,True,123987

Using the manager’s distinguishedName

sAMAccountName,Modify,manager
pjones,True,"CN=James Blunt,OU=Managers,DC=Domain,DC=Com"

*Using the sAMAccountName or employeeID will be slower than using the distinguishedName as the program will need to query Active Directory for the managers distinguishedName value.

Platform Notice: Data Center Only - This article only applies to Atlassian products on the data center platform.

Purpose

Users from Active Directory (AD) are imported into Insight as objects correctly but without Manager attribute by default. This KB is to explain how to map the Manager attribute as an Insight object as well as a Jira user.

Example

An AD user, Maurice Moss has a manager, Jen Barber. Both of them are imported into Insight as an object using predefined structure and configuration. However, Jen is not associated with Maurice as his manager in the object. The expected outcome is to have Jen shown as Maurice's manager as an Insight object, or Jen's Jira user profile in the manager attribute.

Solution

Scenario 1 - Import manager attribute as an Insight object

  1. In the object type which AD users are imported into, add a new attribute for Manager with type Object and choose the object type accordingly.
    How to set manager attribute in Active Directory
  2. In the import configuration, locate the object type mapping for the AD users and map the data locator "manager" with the attribute created from the previous step. An IQL is needed as the attribute is referencing to another object. If you are using predefined configuration, you may use the IQL below as it is.

    distinguishedName = ${manager}


    How to set manager attribute in Active Directory

  3. Run a synchronization and verify if the Manager attribute is populated with the right manager object.

Scenario 2 - Import manager attribute as Jira user

  1. In the object type which AD users are imported into, add a new attribute for Manager with type User.
    How to set manager attribute in Active Directory
  2. In the import configuration, locate the object type mapping for the AD users and map the data locator "manager" with the attribute created from the previous step.
    How to set manager attribute in Active Directory
  3. After adding the attribute mapping, edit the row by clicking on the gear icon on the far right > Configure. Add the following to the Regular expression field and click Update.

  4. Run a synchronization and verify if the Manager attribute is populated with the right Jira user.

Troubleshooting

If the manager attribute is not populated with either or both the solution above, perform the steps below and contact support if needed.

  1. Add another attribute to get the text value of the imported manager data.
  2. In the import configuration, map the attribute with the data locator "manager".
  3. Run a synchronization and verify if the new manager attribute is populated. An expected value is the full DN of the manager which looks like CN=Jen Barber,OU=Employees,DC=michin,DC=internal .
  4. Verify if the user object that is expected to be shown as the manager has the identical DN in the distinguishedName attribute.

Last modified on Apr 5, 2022

Related content

  • No related content found

How do I set up a manager in Active Directory?

A nice feature in Active Directory is the ability to connect users with managers. On the user account you can manually go to the Organization tab, click on the Change button under manager, and type the name of the user's manager. When you look at the same tab for the manager you will see the user under Direct Reports.

How do I get the manager attribute in Active Directory?

The Manager attribute is a pointer to the actual content of the manager's user record. To be able to access the data associated with the manager DN, code must be written to look up user information, and also to look up the manager DN data. This also depends upon the Principal privileges within the Active Directory.

How do I update the manager field in Active Directory?

Search for the manager user based on the email address. Modify the target user manager with the previously user object you get from 1..
$CSV = Import-Csv -path Example_csv. ... .
foreach($line in $CSV) {.
$Manager = Get-ADUser -LDAPFilter "(mail=$($line. ... .
Set-ADUser xxx -Manager $Manager..

What does manager do in Active Directory?

Active Directory management comprises a wide range of tasks, including setting up your domains and forests, keeping your AD organized and healthy, properly managing Group Policy, and ensuring business continuity with a comprehensive backup and recovery process.