Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is another example (@Andy Arismendi was first) with some other details:</p> <ol> <li>If you want to give a user and a password (log onto the server with a different user than the current one), you can use the <code>DirectoryEntry</code> constructor</li> <li>An error that is commonly done is that when you create an object in a directory, the name that represent this object in the directory tree is built with the construction : <code>attribute=value</code>. In Active-Directory you can't choose the the attribute it's imposed by the schema. For a <code>user</code> or an <code>inetOrgPerson</code> it's <code>CN</code> for an <code>organizationalUnit</code> it's <code>OU</code>. In your case the name of the object is <code>CN=Test Person</code>.</li> </ol> <p>You'll find here under the creation of an OU and a user.</p> <pre><code>Clear-Host $dn = New-Object System.DirectoryServices.DirectoryEntry ("LDAP://192.168.234.200:389/dc=dom,dc=fr","administrateur@dom.fr","admin") # Create an OU $Monou = $dn.create("OrganizationalUnit", "ou=Monou") #$Monou.Description = "Une description" $Monou.put("Description", "Une description") $Res = $Monou.Setinfo() # Create a user $objUtilisateur = $Monou.create("inetOrgPerson", "cn=Marc Assin") $objUtilisateur.setinfo() $objUtilisateur.samaccountname = "Massin" $objUtilisateur.givenName = "Marc" $objUtilisateur.sn = "Assin" #$objUtilisateur.displayName = $objUtilisateur.givenName + " " + $objUtilisateur.sn $objUtilisateur.userPrincipalName = "Massin@dom.fr" # Pu the state of the account#$objUtilisateur.SetPassword("test.2010") $objUtilisateur.pwdLastSet = 0 $objUtilisateur.userAccountControl = 544 # Write the datas of the user $objUtilisateur.SetInfo() </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload