把YOS里面生成AD帐户的命令行生成代码共享一下,互通有无:
ASP程序:
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open "select hea.*,he1.employee_name,he2.employee_name as leader_name,hou.organizationunit_name,su.user_name,he1.employee_remark from sys_user su,hr_employeeassign hea,hr_employee he1,hr_employee he2,hr_organizationunit hou where hea.employee_code=he1.employee_code and hea.leader_code=he2.employee_code and hou.organizationunit_code=hea.organizationunit_code and su.employee_code=he1.employee_code order by hea.employeeassign_code desc",conn,1,1
while not rs.eof
%>
dsadd user cn="<%=ucase(rs("employee_code"))%>_<%=ucase(rs("employee_name"))%>",ou=<%=rs("organizationunit_code")%>_<%=rs("organizationunit_name")%>,ou=00_YHG,dc=yanhuagroup,dc=com -pwd 123%abc -upn <%=ucase(rs("user_name"))%>@yanhuagroup.com -samid <%=ucase(rs("user_name"))%> -title <%=rs("Employee_Remark")%> -email <%=lcase(rs("user_name"))%>@yanhuagroup.com -dept <%=rs("OrganizationUnit_Name")%> -pwdneverexpires yes -display <%=ucase(rs("employee_name"))%> -ln <%=ucase(rs("employee_name"))%> -fn <%=ucase(rs("employee_name"))%> -empid <%=ucase(rs("employee_code"))%> -desc <%=ucase(rs("organizationunit_code"))%><br>
<%
rs.movenext
wend
rs.close
%>
rs.open "select hea.*,he1.employee_name,he2.employee_name as leader_name,hou.organizationunit_name,su.user_name,he1.employee_remark from sys_user su,hr_employeeassign hea,hr_employee he1,hr_employee he2,hr_organizationunit hou where hea.employee_code=he1.employee_code and hea.leader_code=he2.employee_code and hou.organizationunit_code=hea.organizationunit_code and su.employee_code=he1.employee_code order by hea.employeeassign_code desc",conn,1,1
while not rs.eof
%>
dsadd user cn="<%=ucase(rs("employee_code"))%>_<%=ucase(rs("employee_name"))%>",ou=<%=rs("organizationunit_code")%>_<%=rs("organizationunit_name")%>,ou=00_YHG,dc=yanhuagroup,dc=com -pwd 123%abc -upn <%=ucase(rs("user_name"))%>@yanhuagroup.com -samid <%=ucase(rs("user_name"))%> -title <%=rs("Employee_Remark")%> -email <%=lcase(rs("user_name"))%>@yanhuagroup.com -dept <%=rs("OrganizationUnit_Name")%> -pwdneverexpires yes -display <%=ucase(rs("employee_name"))%> -ln <%=ucase(rs("employee_name"))%> -fn <%=ucase(rs("employee_name"))%> -empid <%=ucase(rs("employee_code"))%> -desc <%=ucase(rs("organizationunit_code"))%><br>
<%
rs.movenext
wend
rs.close
%>
此页面的前台显示直接粘贴到域控制器的命令行即可。
也可以用其生成文件,由计划任务定期执行,实现自动添加。
(思路为主,细节还可优化)
本文转自 bingyizy 51CTO博客,原文链接:http://blog.51cto.com/bingyi/368733,如需转载请自行联系原作者