Hi Adaxes,
I'm struggling to create an AD user in Adaxes via PowerShell, here's part of the script I have, the user information is coming from a REST API query
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")
# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")
# Bind to the Organizational Unit
$parent = $admService.OpenObject("Adaxes://OU=New Starters,OU=Users,DC=domain,DC=com",
$NULL, $NULL, 0)
$manager = ""
$manager = $result.ReportsToEmployeeId.DisplayValue.Trim().ToString()
$manager = get-admuser -filter {employeeID -eq $manager}
$Context.LogMessage("Name: $($result.FirstName.DisplayValue).$($result.LastName.DisplayValue)", "Information")
$Context.LogMessage("Company: $($result.Company.DisplayValue)", "Information")
$Context.LogMessage("Department: $($result.Department.DisplayValue)", "Information")
$Context.LogMessage("DisplayName: $($result.FirstName.DisplayValue) $($result.LastName.DisplayValue)", "Information")
$Context.LogMessage("EmployeeID: $($result.EmployeeId.DisplayValue)", "Information")
$Context.LogMessage("GivenName: $($result.FirstName.DisplayValue)", "Information")
$Context.LogMessage("Manager: $($manager.UserPrincipalName)", "Information")
$Context.LogMessage("Office: $($result.Location.DisplayValue)", "Information")
$Context.LogMessage("EmployeeType: $($result.EmployeeType.DisplayValue)", "Information")
$Context.LogMessage("SamAccountName: $($result.FirstName.DisplayValue).$($result.LastName.DisplayValue)", "Information")
$Context.LogMessage("Title: $($result.JobRole.DisplayValue)", "Information")
$Context.LogMessage("UserPrincipalName: $($result.FirstName.DisplayValue).$($result.LastName.DisplayValue)@Quantadt.com", "Information")
$Context.LogMessage("Email: $($result.EmailId.DisplayValue)", "Information")
$Context.LogMessage("", "Information")
# Create a new user object (PowerShell)
New-AdmUser -Name "$($result.FirstName.DisplayValue.Trim().ToString()).$($result.LastName.DisplayValue.Trim().ToString())" `
-Company "$($result.Company.DisplayValue)" `
-Department "$($result.Department.DisplayValue)" `
-DisplayName "$($result.FirstName.DisplayValue) $($result.LastName.DisplayValue)" `
-EmployeeID "$($result.EmployeeId.DisplayValue)" `
-GivenName "$($result.FirstName.DisplayValue)" `
-Manager $manager `
-Office "$($result.Location.DisplayValue)" `
-OtherAttributes @{'EmployeeType'="$($result.EmployeeType.DisplayValue)"} `
-Path "OU=New Starters,OU=QFSUsers,DC=uk,DC=quantafs" `
-Surname "$($result.LastName.DisplayValue)" `
-Title "$($result.JobRole.DisplayValue)" `
-SamAccountName "$($result.FirstName.DisplayValue.Trim().ToString()).$($result.LastName.DisplayValue.Trim().ToString())" `
-UserPrincipalName "$($result.FirstName.DisplayValue.Trim().ToString()).$($result.LastName.DisplayValue.Trim().ToString())@Quantadt.com"
# Create a new user object (ADSI)
$user = $parent.Create("user", "$($result.FirstName.DisplayValue.Trim().ToString()) $($result.LastName.DisplayValue.Trim().ToString())")
$user.Put("Company", "$($result.Company.DisplayValue)")
$user.Put("DisplayName", "$($result.FirstName.DisplayValue) $($result.LastName.DisplayValue)")
$user.Put("EmployeeID", "$($result.EmployeeID.DisplayValue)")
$user.Put("givenName", "$($result.FirstName.DisplayValue)")
$user.Put("Manager", "$($manager.DistinguishedName)")
$user.Put("Office", "$($result.Location.DisplayValue)")
$user.Put("EmployeeType", "$($result.EmployeeType.DisplayValue)")
$user.Put("sn", "$($result.LastName.DisplayValue)")
$user.Put("sAMAccountName", "$($result.FirstName.DisplayValue.Trim().ToString()).$($result.LastName.DisplayValue.Trim().ToString())")
$user.Put("Title", "$($result.JobRole.DisplayValue)")
$user.Put("UserPrincipalName", "$($result.FirstName.DisplayValue.Trim().ToString()).$($result.LastName.DisplayValue.Trim().ToString())@Quantadt.com")
# Save the user account to the directory
$user.SetInfo()
Here's the output I get from the logs
Name: Joe.Bloggs
Company: Example
Department: Example Department
DisplayName: Joe Bloggs
EmployeeID: 12345
GivenName: Joe
Manager: jane.bloggs@example.com
Office: Headquarters
EmployeeType: Employee
SamAccountName: Joe.Bloggs
Title: Manager
UserPrincipalName: joe.bloggs@example.com
Email: joebloggs@outlook.com
An error occurred when creating user 'Joe Bloggs'. Error: Exception calling "SetInfo" with "0" argument(s): "DN 'Joe Bloggs,OU=New Starters,OU=Users,DC=domain,DC=com' is invalid."
I also tried removing all the information being provided by the API by just running the below and that gave the same error:
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")
# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")
# Bind to the Organizational Unit
$parent = $admService.OpenObject("Adaxes://OU=New Starters,OU=Users,DC=domain,DC=com",
$NULL, $NULL, 0
# Create a new user object (ADSI)
$user = $parent.Create("user", "Joe Bloggs")
I've checked the OU and there's no property patterns applied (was thinking there were some requirements)