3 # Test for 'samba-tool user edit'
7 Usage: user_edit.sh SERVER USERNAME PASSWORD
17 . $STpath/testprogs/blackbox/subunit.sh
20 display_name_b64="QmrDtnJu"
21 display_name_new="Renamed Bjoern"
22 # attribute value including control character
23 # echo -e "test \a string" | base64
24 display_name_con_b64="dGVzdCAHIHN0cmluZwo="
26 tmpeditor=$(mktemp --suffix .sh -p $STpath/bin samba-tool-editor-XXXXXXXX)
30 $PYTHON ${STpath}/source4/scripting/bin/samba-tool \
31 user create sambatool1 --random-password \
32 -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
37 cat >$tmpeditor <<-'EOF'
41 $SED -i -e 's/userAccountControl: 512/userAccountControl: 514/' $user_ldif
44 $PYTHON ${STpath}/source4/scripting/bin/samba-tool \
45 user edit sambatool1 --editor=$tmpeditor \
46 -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
49 # Test edit user - add base64 attributes
50 add_attribute_base64() {
56 grep -v '^$' \$user_ldif > \${user_ldif}.tmp
57 echo "displayName:: $display_name_b64" >> \${user_ldif}.tmp
59 mv \${user_ldif}.tmp \$user_ldif
62 $PYTHON ${STpath}/source4/scripting/bin/samba-tool user edit \
63 sambatool1 --editor=$tmpeditor \
64 -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
67 get_attribute_base64() {
68 $PYTHON ${STpath}/source4/scripting/bin/samba-tool user show \
69 sambatool1 --attributes=displayName \
70 -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
79 grep -v '^displayName' \$user_ldif >> \${user_ldif}.tmp
80 mv \${user_ldif}.tmp \$user_ldif
82 $PYTHON ${STpath}/source4/scripting/bin/samba-tool user edit \
83 sambatool1 --editor=$tmpeditor \
84 -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
87 # Test edit user - add base64 attribute value including control character
88 add_attribute_base64_control() {
94 grep -v '^$' \$user_ldif > \${user_ldif}.tmp
95 echo "displayName:: $display_name_con_b64" >> \${user_ldif}.tmp
97 mv \${user_ldif}.tmp \$user_ldif
99 $PYTHON ${STpath}/source4/scripting/bin/samba-tool user edit \
100 sambatool1 --editor=$tmpeditor \
101 -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
104 get_attribute_base64_control() {
105 $PYTHON ${STpath}/source4/scripting/bin/samba-tool user show \
106 sambatool1 --attributes=displayName \
107 -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
111 # Test edit user - change base64 attribute value including control character
112 change_attribute_base64_control() {
114 cat >$tmpeditor <<EOF
118 sed -i -e 's/displayName:: $display_name_con_b64/displayName: $display_name/' \
121 $PYTHON ${STpath}/source4/scripting/bin/samba-tool user edit \
122 sambatool1 --editor=$tmpeditor \
123 -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
126 get_attribute_base64_control() {
127 $PYTHON ${STpath}/source4/scripting/bin/samba-tool user show \
128 sambatool1 --attributes=displayName \
129 -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
132 # Test edit user - change attributes with LDB_FLAG_FORCE_NO_BASE64_LDIF
133 change_attribute_force_no_base64() {
135 # Expects that the original attribute is available as clear text,
136 # because the LDB_FLAG_FORCE_NO_BASE64_LDIF should be used here.
137 cat >$tmpeditor <<EOF
141 sed -i -e 's/displayName: $display_name/displayName: $display_name_new/' \
145 $PYTHON ${STpath}/source4/scripting/bin/samba-tool user edit \
146 sambatool1 --editor=$tmpeditor \
147 -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
150 get_changed_attribute_force_no_base64() {
151 $PYTHON ${STpath}/source4/scripting/bin/samba-tool user show \
152 sambatool1 --attributes=displayName \
153 -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
157 $PYTHON ${STpath}/source4/scripting/bin/samba-tool \
158 user delete sambatool1 \
159 -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD"
164 testit "create_test_user" create_test_user || failed=`expr $failed + 1`
165 testit "edit_user" edit_user || failed=`expr $failed + 1`
166 testit "add_attribute_base64" add_attribute_base64 || failed=`expr $failed + 1`
167 testit_grep "get_attribute_base64" "^displayName:: $display_name_b64" get_attribute_base64 || failed=`expr $failed + 1`
168 testit "delete_attribute" delete_attribute || failed=`expr $failed + 1`
169 testit "add_attribute_base64_control" add_attribute_base64_control || failed=`expr $failed + 1`
170 testit_grep "get_attribute_base64_control" "^displayName:: $display_name_con_b64" get_attribute_base64_control || failed=`expr $failed + 1`
171 testit "change_attribute_base64_control" change_attribute_base64_control || failed=`expr $failed + 1`
172 testit_grep "get_attribute_base64_control" "^displayName:: $display_name_b64" get_attribute_base64_control || failed=`expr $failed + 1`
173 testit "change_attribute_force_no_base64" change_attribute_force_no_base64 || failed=`expr $failed + 1`
174 testit_grep "get_changed_attribute_force_no_base64" "^displayName: $display_name_new" get_changed_attribute_force_no_base64 || failed=`expr $failed + 1`
175 testit "delete_user" delete_user || failed=`expr $failed + 1`