[Samba] Import USER and PASSWORD Samba3+OpenLadp TO Samba4

Rowland Penny rowlandpenny241155 at gmail.com
Wed Aug 26 15:56:46 UTC 2015


On 26/08/15 16:26, L.P.H. van Belle wrote:
> Hai,
> just make a CSV file and import your users.
>
> this is the script i used.
>
> #!/bin/bash
> ## example
> ## display naam in AD wil be : Louis van Belle (
> cat /home/samba/backup/users.csv | awk -F ";" '{system("/usr/bin/samba-tool user add "$5" --mail-address="$7" \
> --given-name="$4" --surname=\""$3"\" --telephone-number="$6" --department="$1" --description=\""$1"\" \
> --random-password --userou=ou=Company")}';
>
> the layout of the CSV( which i got from an export of my samba3+ldap)
> IT-Department;L.P.H.;van Belle;Louis;my-loginname;phonenummer;e-mail at domain.tld;
>
> use : samba-tool user add --help
> for more examples
>
> this is how it for you would be.. where the password is WelkomUsername
>
> /usr/bin/samba-tool user add "$5" "Welkom$5" --mail-address="$7" \
> --given-name="$2" --surname=\""$3"\" --telephone-number="$6" \
> --department="$1" --description=\""$1"\" --userou=ou=Company \
> --must-change-at-next-login
>
> Just notice that i made an separated OU for my company.. ( see also the help )
>
>
> Greetz,
>
> Louis
>
>
>> -----Oorspronkelijk bericht-----
>> Van: samba [mailto:samba-bounces at lists.samba.org] Namens vinifa
>> Verzonden: woensdag 26 augustus 2015 17:01
>> Aan: samba at lists.samba.org
>> Onderwerp: Re: [Samba] Import USER and PASSWORD
>> Samba3+OpenLadp TO Samba4
>>
>> Really did not work, if I create a user in RSAT no password,
>> and select the
>> option to change password at next logon, works. Now if I
>> import the LDIF
>> even enabling this function does not work. This issue of
>> password, you know
>> how I can put a default password for all users, such as 123456?
>>
>> I did not understand what you sent me.
>>
>> replace: unicodePwd
>> unicodePwd :: $ unicodePwd "
>>
>> To get $ unicodePwd, I would do this:
>>
>> UnicodePwd = $ (echo -n "\" $ _ user_pw \ "" | $ _ICONV -f -t
>> UTF-8 UTF-16LE
>> |
>> $ _BASE64 -w 0)
>>
>>
>>
>> --
>> View this message in context:
>> http://samba.2283325.n4.nabble.com/Import-USER-and-PASSWORD-Sam
>> ba3-OpenLadp-TO-Samba4-tp4690180p4690271.html
>> Sent from the Samba - General mailing list archive at Nabble.com.
>>
>> -- 
>> To unsubscribe from this list go to the following URL and read the
>> instructions:  https://lists.samba.org/mailman/options/samba
>>
>>
>

Hi Louis,
I actually advised him to do something similar with his ldif.

Vinifa,
What I posted was a piece of code from a bash script I wrote to add Unix 
users to AD,this is it again:

  UNICODEPWD=$(echo -n "\"$_USER_PW\"" | $_ICONV -f UTF-8 -t UTF-16LE | 
$_BASE64 -w 0)


It sets the variable 'UNICODEPWD' to what running the code inside the 
brackets produces.

i.e. if the users password is to be 'password' , 'echo -n \"password\" | 
iconv -f UTF-8 -t UTF-16LE | base64 -w 0'

The '|' means 'pass' or more correctly 'pipe' the result of the left 
hand command to the command on the right, the '\' signs are important, 
they escape the quote marks which MUST be there.

  Rowland




More information about the samba mailing list