<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
|
<%Session.CodePage=65001%>
|
<!--#include file="JsonPost_user.gds"-->
|
<!--#include virtual="/inc/function.gds"-->
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<%
|
'更新成员
|
Set rs = Server.CreateObject("ADODB.Recordset")
|
access_token=GetAccess_token_contactsApi()
|
|
appUrl="https://qyapi.weixin.qq.com/cgi-bin/user/update?access_token="&access_token
|
|
OA_UserID = trim(Request("OA_UserID"))
|
|
If OA_UserID="" Then Response.Redirect "/"
|
sql="select * from OA_User where OA_User_ID="&OA_UserID
|
rs.open sql,objConn,1,1
|
if not rs.Eof then
|
OA_weixinUserID = rs("OA_weixinUserID")
|
OA_Name = rs("OA_Name")
|
OA_DepartmentID = rs("OA_DepartmentID")
|
OA_DepartmentIDs= rs("OA_DepartmentIDs")
|
OA_Position = rs("OA_Position")
|
OA_mobile = rs("OA_mobile")
|
OA_gender = rs("OA_gender")
|
OA_email = rs("OA_email")
|
OA_IdentityCard = rs("OA_IdentityCard")
|
OA_weixinID = rs("OA_weixinID")
|
OA_execLevel = rs("OA_execLevel")
|
OA_weixinStatus = rs("OA_weixinStatus")
|
If OA_DepartmentIDs<>"" Then OA_DepartmentID=OA_DepartmentIDs
|
If OA_execLevel=-1 Then
|
enable=0
|
Else
|
enable=1
|
End if
|
end if
|
rs.close()
|
|
If OA_weixinUserID="" Then Response.Redirect "/AdminUser.gds?userID="&OA_UserID&"&h_menu1_1="&session("h_menu1_1")&"&SystemMessageType=4&SMT=2"
|
|
m=1
|
If m=1 Then '离职删除企微账号
|
If enable=0 And OA_weixinStatus<>2 Then '删除
|
appUrl="https://qyapi.weixin.qq.com/cgi-bin/user/delete"
|
If OA_weixinUserID="" Then Response.Redirect "/"
|
Origin="access_token="&access_token&"&userid="&OA_weixinUserID
|
HTMLCODE= GetBody(appUrl,Origin)
|
sql="update OA_User set OA_weixinStatus=2 where OA_User_ID="&OA_UserID
|
objConn.Execute sql
|
|
ElseIf enable=1 And OA_weixinStatus=2 Then '新建
|
appUrl="https://qyapi.weixin.qq.com/cgi-bin/user/create?access_token="&access_token
|
args1="{"
|
args1=args1&"""userid"": """&OA_weixinUserID&""""
|
If OA_Name<>"" Then args1=args1&",""name"": """&OA_Name&""""
|
If OA_DepartmentID<>"" Then args1=args1&",""department"": ["&OA_DepartmentID&"]"
|
If OA_Position<>"" Then args1=args1&",""position"": """&OA_Position&""""
|
If OA_mobile<>"" Then args1=args1&",""mobile"": """&OA_mobile&""""
|
If OA_gender<>"" Then args1=args1&",""gender"": """&OA_gender&""""
|
If OA_email<>"" Then args1=args1&",""email"": """&OA_email&""""
|
If OA_IdentityCard<>"" Then args1=args1&",""extattr"":{""attrs"":[{""type"":0,""name"":""身份证"",""text"": {""value"": """&OA_IdentityCard&"""}}]}"
|
If OA_weixinID<>"" Then args1=args1&",""weixinid"": """&OA_weixinID&""""
|
args1=args1&"}"
|
HTMLCODE= PostBody(appUrl,args1)
|
sql="update OA_User set OA_weixinStatus=4 where OA_User_ID="&OA_UserID
|
objConn.Execute sql
|
|
ElseIf enable=1 Then '修改
|
appUrl="https://qyapi.weixin.qq.com/cgi-bin/user/update?access_token="&access_token
|
args1="{"
|
args1=args1&"""userid"": """&OA_weixinUserID&""""
|
If OA_Name<>"" Then args1=args1&",""name"": """&OA_Name&""""
|
If OA_DepartmentID<>"" Then args1=args1&",""department"": ["&OA_DepartmentID&"]"
|
If OA_Position<>"" Then args1=args1&",""position"": """&OA_Position&""""
|
If OA_mobile<>"" Then args1=args1&",""mobile"": """&OA_mobile&""""
|
If OA_gender<>"" Then args1=args1&",""gender"": """&OA_gender&""""
|
If OA_email<>"" Then args1=args1&",""email"": """&OA_email&""""
|
If OA_IdentityCard<>"" Then args1=args1&",""extattr"":{""attrs"":[{""type"":0,""name"":""身份证"",""text"": {""value"": """&OA_IdentityCard&"""}}]}"
|
If OA_weixinID<>"" Then args1=args1&",""weixinid"": """&OA_weixinID&""""
|
args1=args1&",""enable"": "&enable&""
|
args1=args1&"}"
|
HTMLCODE= PostBody(appUrl,args1)
|
End If
|
Else
|
'离职停用企微账号
|
If enable=0 And OA_weixinStatus<>2 And OA_weixinUserID<>"" Then '离职停用
|
appUrl="https://qyapi.weixin.qq.com/cgi-bin/tag/addtagusers?access_token="&access_token
|
args1="{"
|
args1=args1&"""tagid"": 5"
|
args1=args1&",""userlist"": ["""&OA_weixinUserID&"""]"
|
args1=args1&"}"
|
HTMLCODE= PostBody(appUrl,args1)
|
ElseIf enable=1 And OA_weixinUserID<>"" Then '修改
|
appUrl="https://qyapi.weixin.qq.com/cgi-bin/tag/deltagusers?access_token="&access_token
|
args1="{"
|
args1=args1&"""tagid"": 5"
|
args1=args1&",""userlist"": [ """&OA_weixinUserID&"""]"
|
args1=args1&"}"
|
HTMLCODE= PostBody(appUrl,args1)
|
End If
|
access_token=GetAccess_token_contactsApi()
|
|
appUrl="https://qyapi.weixin.qq.com/cgi-bin/user/update?access_token="&access_token
|
args1="{"
|
args1=args1&"""userid"": """&OA_weixinUserID&""""
|
If OA_Name<>"" Then args1=args1&",""name"": """&OA_Name&""""
|
If OA_DepartmentID<>"" Then args1=args1&",""department"": ["&OA_DepartmentID&"]"
|
If OA_Position<>"" Then args1=args1&",""position"": """&OA_Position&""""
|
If OA_mobile<>"" Then args1=args1&",""mobile"": """&OA_mobile&""""
|
If OA_gender<>"" Then args1=args1&",""gender"": """&OA_gender&""""
|
If OA_email<>"" Then args1=args1&",""email"": """&OA_email&""""
|
If OA_IdentityCard<>"" Then args1=args1&",""extattr"":{""attrs"":[{""type"":0,""name"":""身份证"",""text"": {""value"": """&OA_IdentityCard&"""}}]}"
|
If OA_weixinID<>"" Then args1=args1&",""weixinid"": """&OA_weixinID&""""
|
args1=args1&",""enable"": "&enable&""
|
args1=args1&"}"
|
|
'Response.Write args1&"<br><br>"
|
HTMLCODE= PostBody(appUrl,args1)
|
'Response.Write HTMLCODE&"<br><br>"
|
'Response.End
|
End If
|
|
|
|
if PositionURLID="1" then PositionURLID=11
|
ReturnURL=session("PositionURL"&PositionURLID-1)
|
if InStr(ReturnURL,"?")<1 then
|
ReturnURL=ReturnURL&"?ReturnURLID="&(PositionURLID-1)
|
else
|
ReturnURL=ReturnURL&"&ReturnURLID="&(PositionURLID-1)
|
end If
|
|
If Mid(HTMLCODE,12,1)="0" Then
|
Response.Redirect ReturnURL&"&SystemMessageType=3&SMT=4"
|
Else
|
Response.Write HTMLCODE&"<br><br>"
|
'Response.Redirect ReturnURL&"&SystemMessageType=4&SMT="&HTMLCODE
|
End If
|
%>
|