Jump to content

Create User in Active Directory


Recommended Posts

Hello, I want create a new user in the Active directory with Autoit.

I try that sicnce weeks. I have found many scripts from many users - but not one can create a user for the active directory.

i know how to connect and how to change some attributes. But i cant find the solution to create a user with autoit.

Thx for any solution!!!

Link to comment
Share on other sites

  • Developers

Hello, I want create a new user in the Active directory with Autoit.

I try that sicnce weeks. I have found many scripts from many users - but not one can create a user for the active directory.

i know how to connect and how to change some attributes. But i cant find the solution to create a user with autoit.

Thx for any solution!!!

Maybe post what you have and doesn't work ?

:)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

for example, i have found this:

$userou = "testou"

$user = "testuser"

$fname = "firstname"

$lname = "lastname"

$description = "beschreibung"

Call ("CreateUser")

Func CreateUser($userou, $user, $fname, $lname, $description = "User")

;If ObjectExists($user) Then Return 0

Dim $objConnection, $objRootDSE

$objConnection = ObjCreate("ADODB.Connection") ; Create COM object to AD

$objConnection.Provider = "ADsDSOObject"

$objConnection.Open ("Active Directory Provider") ; Open connection to AD

$objRootDSE = ObjGet("LDAP://RootDSE")

$ObjOU = ObjGet("LDAP://" & $userou)

$cnname = "CN=" & $lname & "\, " & $fname

$ObjUser = $ObjOU.Create ("User", $cnname)

$ObjUser.Put ("sAMAccountName", $user)

$ObjUser.Put ("description", $description)

$ObjUser.SetInfo

Return 1

EndFunc ;==>CreateUser

No error and no working, maybe no Password?

Link to comment
Share on other sites

This i have tried too.

#include <Array.au3>

; Define AD Constants

Global Const $ADS_GROUP_TYPE_GLOBAL_GROUP = 0x2

Global Const $ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP = 0x4

Global Const $ADS_GROUP_TYPE_UNIVERSAL_GROUP = 0x8

Global Const $ADS_GROUP_TYPE_SECURITY_ENABLED = 0x80000000

Global $ADS_GROUP_TYPE_GLOBAL_SECURITY = BitOR($ADS_GROUP_TYPE_GLOBAL_GROUP, $ADS_GROUP_TYPE_SECURITY_ENABLED)

; CreateUser

$userou = "users=OU, OINK=DC, LOCAL=DC" ; Form is "sampleou=ou, sampleparent=ou, sampledomain1=dc, sampledomain2=dc, sampledomain3=dc"

$user = "Username" ;Username, form is SamAccountName without leading 'CN='

$fname = "First Name"

$lname = "Last Name"

$description = "optional - Description"

Call ("CreateUser")

Func CreateUser($userou, $user, $fname, $lname, $description = "User")

If ObjectExists($user) Then Return 0

Dim $objConnection, $objRootDSE

$objConnection = ObjCreate("ADODB.Connection") ; Create COM object to AD

$objConnection.Provider = "ADsDSOObject"

$objConnection.Open ("Active Directory Provider") ; Open connection to AD

$objRootDSE = ObjGet("LDAP://RootDSE")

$ObjOU = ObjGet("LDAP://" & $userou)

$cnname = "CN=" & $lname & "\, " & $fname

$ObjUser = $ObjOU.Create ("User", $cnname)

$ObjUser.Put ("sAMAccountName", $user)

$ObjUser.Put ("description", $description)

$ObjUser.SetInfo

Return 1

EndFunc ;==>CreateUser

no error and no function ;(

Link to comment
Share on other sites

@fry2k

Can this help you out.

Dim $objDomain, $objUser

$objDomain = ObjGet("LDAP://cn=Users,dc=mycorp,dc=com")
$objUser = $objDomain.Create("user","cn=vlaunders")
$objUser.Put ("sAMAccountName", "vlaunders")
$objUser.Put ("userPrincipalName", "vlaunders@mycorp.com")

Don't forget to change the LDAP data to your settings.

regards

ptrex

Link to comment
Share on other sites

thx,

i was trying this. but no error und no function ;(

Dim $objDomain, $objUser

$objDomain = ObjGet("LDAP://cn=Users,dc=OINK,dc=LOCAL")

$objUser = $objDomain.Create("user","cn=vlaunders")

$objUser.Put ("sAMAccountName", "vlaunders")

$objUser.Put ("userPrincipalName", "vlaunders@OINK.LOCAL")

has nobody an idea how to create? i mean how to change i know, but i cant find out how to create ;(

PLZ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...