Sorry, search feature is not supported in Internet Explorer 11

Creating user accounts

The following code sample creates a user account in the specified Organizational Unit.


# 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=Sales,DC=company,DC=com",
    $NULL, $NULL, 0)

# Create a new user object
$user = $parent.Create("user", "CN=John Smith")

# First name
$user.Put("givenName", "John")
# Last name
$user.Put("sn", "Smith")
# User logon name (pre-Windows 2000)
$user.Put("sAMAccountName", "jsmith")
# Password
$user.Put("unicodePwd", "secret")
# Must change password at first logon
$user.Put("pwdLastSet", 0)
# Account is enabled
$user.AccountDisabled = $False

# Save the user account to the directory
Import-Module Adaxes

$parentDN = "OU=Sales,DC=company,DC=com"
$domain = ""

$name = "John Smith"
$firstName = "John"
$lastName = "Smith"
$password = ConvertTo-SecureString "secret" -AsPlainText -Force
$username = "jsmith"

New-AdmUser $name -Path $parentDN `
    -GivenName $firstName -Surname $lastName -SamAccountName $username `
    -AccountPassword $password -ChangePasswordAtLogon $True -Enabled $True `
    -Server $domain -AdaxesService localhost

See also