修改Oracle用户密码的方法

复制Sub gen_pass_app() Dim bit_count as integer ’循环变量,修改 密码中位数计数器 dim row_num as integer ’需生成密码的用户名信息开始的行号 dim rnd_base As Integer ’随机数种子 Dim char_value As Integer ’密码中每个字符的 ascii 值 Dim temp_str As String ’密码串 Dim username(50) As String ’用户名 dim pass_length as integer ’定义生成的密码的长度 dim start_asc as integer ’ 定义从哪个字符开始生成 pass_length = 8 ’ 设定密码长度为 8 位 Rem start_asc = 48 ’ 设定密码从 0 开始 start_asc = 65 ’ 设定密码从 A 开始 rem 由于 Oracle 数据库用户密码不区分大小写,故,用户视所选择的密码起始字母,决定随机数 rnd_base = 90 - start_asc ?修改 rem 打开文件,用于输出生成的用户改密码的脚本 Open "c:change_pass.sql" For Output As #1 rem 同时,在工作表上记录相应的密码密码,以便打印出来备作为记录,修改此处为先写标题 Cells(1,用户 1) = "Username": Cells(1, 2) = "Password" Cells(1, 3) = "Username": Cells(1, 4) = "Password" rem 先生成 apps 的密码,但脚本中加上注释,密码因 apps密码必须与应用程序一起改 rem 先初始化密码串为空白 temp_str = "" For bit_count = 1 To pass_length char_value = start_asc + Int(Rnd(1) * rnd_base) rem 此处为为防=号引起 excel 误认为是服务器租用修改公式,从而程序出错。用户 If char_value = 61 Then char_value = 62 End If rem 组合成密码 temp_strtemp_str = temp_str + Chr$(char_value) Next bit_count rem 将生成的密码 apps 密码输出到脚本文件 Print #1, "REM alter user apps" + " identified by " + temp_str + ";" rem 同时,记录在工作表上 Cells(2,修改 3) = "APPS": Cells(2, 4) = temp_str rem 需生成密码的用户名从 row_num 行开始 row_num = 2 rem 若***列非空,则创建密码,用户否则退出 Do While Cells(row_num,密码 1) <> "" temp_str = "" For bit_count = 1 To pass_length char_value = start_asc + Int(Rnd(1) * rnd_base) If char_value = 61 Then char_value = 62 End If temp_strtemp_str = temp_str + Chr$(char_value) Next bit_count Print #1, "alter user " + Cells(row_num, 1) + " identified by " + temp_str + Cells(row_num, 2) = temp_str rem 获取下一行 row_numrow_num = row_num + 1 Loop rem 所有用户的密码已生成,关闭文件 Close #1 End Sub ? Sub gen_pass_unix() Dim bit_count as integer ’循环变量, 密码中位数计数器 dim row_num as integer ’需生成密码的用户名信息开始的行号 dim rnd_base As Integer ’随机数种子 Dim char_value As Integer ’密码中每个字符的 ascii 值 Dim temp_str As String ’密码串 Dim username(50) As String ’用户名 dim pass_length as integer ’定义生成的密码的长度 dim start_asc as integer ’ 定义从哪个字符开始生成 pass_length = 8 start_asc = 48 ’ 0 Rem start_asc = 65 ’ A rem 由于 unix 密码支持大小写,故,视所选择的起始字母,决定随机数的源码下载范围,以确保 rnd_base = 122 - start_asc ? rem 打开文件,用于输出生成的改密码的脚本 Open "c:change_pass.txt" For Output As #1 rem 同时,在工作表上记录相应的密码,以便打印出来备作为记录,此处为先写标题 Cells(1, 3) = "Username": Cells(1, 4) = "Password" row_num = 2 rem 若第三列非空,则创建密码,否则退出 Do While Cells(row_num, 3) <> "" temp_str = "" For bit_count = 1 To pass_length char_value = start_asc + Int(Rnd(1) * rnd_base) rem 91-94 为 [ ] ^ _ ` rem 因不愿在unix 密码串中包含该类字符,故,通过减少已增大的计数器以保证密码的长度,同时,不将其计入密码串中,以排除它们 If (char_value >= 58 And char_value <= 64) Or (char_value >= 91 And char_value <= 96) Then bit_countbit_count = bit_count - 1 Else temp_strtemp_str = temp_str + Chr$(char_value) End If Next bit_count Print #1, "user " + Cells(row_num, 1) + " : " + temp_str Cells(row_num, 4) = temp_str rem 获取下一行 row_numrow_num = row_num + 1 Loop rem 所有用户的密码已生成,云服务器关闭文件 Close #1 End Sub 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.