L.P.H. van Belle
2015-Aug-26 15:26 UTC
[Samba] Import USER and PASSWORD Samba3+OpenLadp TO Samba4
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 > >
Rowland Penny
2015-Aug-26 15:56 UTC
[Samba] Import USER and PASSWORD Samba3+OpenLadp TO Samba4
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
Hello! Good evening, thanks for your help! I could import the users of my CSV for my Samba4 following its recommendations, but unfortunately there's something wrong, despite the user there, it does not work, give a klist to check the credential, returns me the error: kinit: Client 'user2 at DOMAIN.LOCAL' not found in Kerberos database while getting initial credentials Even if I change the password through the RSAT, it does not. I also noticed something when I give getent passwd returns me the user a little different. Looks like was: DOMAIN\user1:*:3000345:100: User1 Test: /home/DOMAIN/user1:/bin/false :/bin/false100::/home/DOMAIN/user2 This problem happened to you? That's my CSV server:/tmp# cat export_novo.csv COMPANY; User1; Test; user1 The simple command, with only User and Password looked like this: cat export_novo.csv | awk -F ";" '{system("samba-tool user add "$4" "pass$4"")}'; -- View this message in context: http://samba.2283325.n4.nabble.com/Import-USER-and-PASSWORD-Samba3-OpenLadp-TO-Samba4-tp4690180p4690327.html Sent from the Samba - General mailing list archive at Nabble.com.
Thank Rowland Penny-6 and L.P.H. Van Belle for all the help I could not do that users were exported from script, but I got a "trigger" to matter the bills ... was ugly to look at, but for me it worked. I exported the CSV, then edited, made a statement block where each line I gave the samba-tool user add, edit in Excel and Notepad ++ to find and replace ... it took me 10 minutes to do 300 users ... LOL Anyway, I am very grateful for your help, thank you! ########################################################### #/bin/bash samba-tool user add user1 pass --given-name=User --surname="Test" --description=departament --userou=ou=SMB3 --must-change-at-next-login; samba-tool user add user2 pass --given-name=User2 --surname="Test" --description=departament --userou=ou=SMB3 --must-change-at-next-login; ########################################################### -- View this message in context: http://samba.2283325.n4.nabble.com/Import-USER-and-PASSWORD-Samba3-OpenLadp-TO-Samba4-tp4690180p4690606.html Sent from the Samba - General mailing list archive at Nabble.com.