Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1061 lines
34 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' group_prop.asp: Serves in changing the properties of the groups
  6. '
  7. ' Copyright (c) Microsoft Corporation. All rights reserved.
  8. '
  9. ' Date Description
  10. ' 16-Jan-2001 Creation Date.
  11. '-------------------------------------------------------------------------
  12. %>
  13. <!-- #include virtual="/admin/inc_framework.asp" -->
  14. <!-- #include virtual="/admin/inc_accountsgroups.asp" -->
  15. <!-- #include file="inc_usersNgroups.asp" -->
  16. <%
  17. '-------------------------------------------------------------------------
  18. ' Global Constants and Variables
  19. '-------------------------------------------------------------------------
  20. Dim rc 'Return value for CreatePage
  21. Dim page 'Variable that receives the output page object when
  22. Dim G_objService 'To get WMI connection
  23. Dim idGeneralTab 'Variable for General tab
  24. Dim idMembersTab 'Variable for Members tab
  25. Dim G_strGroupName 'group name
  26. Dim G_CREDENTIAL_ERROR 'Error constant
  27. Const GC_ERR_ACCESS_DENIED = &H80070005
  28. '-------------------------------------------------------------------------
  29. ' Global Form Variables
  30. '-------------------------------------------------------------------------
  31. Dim F_strGroupName 'Group name
  32. Dim F_strGrpDescription 'Group description
  33. Dim F_strGroupMembers 'Group members
  34. Dim F_strCurrentGroupMembers 'Current memebers of the group
  35. Dim F_strOldGrpDescription 'old group description
  36. Dim F_strOldGroupName 'old group name
  37. Dim F_strGroupsAdded 'groups to be added
  38. Dim F_strGroupsRemoved 'groups to be removed
  39. Dim F_strCredentialID 'CredentialId
  40. Dim F_strCredentialPSW 'Credential Password
  41. 'getting the group name from area page
  42. '======================================================
  43. ' Entry point
  44. '======================================================
  45. Dim L_TASKTITLE_TEXT
  46. Dim L_GENERAL_TEXT
  47. Dim L_MEMBERS_TEXT
  48. Dim L_GROUP_NAME_TEXT
  49. Dim L_DESCRIPTION_TEXT
  50. Dim L_MEMBERSPROMPT_TEXT
  51. Dim L_ADDUSERORGROUP_TEXT
  52. Dim L_ADD_TEXT
  53. Dim L_REMOVE_TEXT
  54. Dim L_DOMAINUSERHELP_TEXT
  55. Dim L_HOWTO_ADDDOMAINUSER
  56. Dim L_HOWTO_ENTERCREDENTIALS
  57. Dim L_USERNAME_PROMPT
  58. Dim L_PASSWORD_PROMPT
  59. 'error messages
  60. Dim L_GROUPPROPNOTOBTAINED_ERRORMESSAGE
  61. Dim L_GROUPNOTPRESENT_ERRORMESSAGE
  62. Dim L_GROUPNAMENOTVALID_ERRORMESSAGE
  63. Dim L_INVALIDCHARACTER_ERRORMESSAGE
  64. Dim L_LONGGRPDESCRIPTION_ERRORMESSAGE
  65. Dim L_SELECTMEMBER_ERRORMESSAGE
  66. Dim L_DOMUSERINVALIDCHARACTER_ERRORMESSAGE
  67. Dim L_DUPLICATEMEMBER_ERRORMESSAGE
  68. Dim L_INVALIDDOMAINUSER_ERRORMESSAGE
  69. Dim L_DESCRIPTIONUPDATEFAILED_ERRORMESSAGE
  70. Dim L_USERNOTFOUND_ERRORMESSAGE
  71. Dim L_MEMBERUPDATIONFAILED_ERRORMESSAGE
  72. Dim L_NONUNIQUEGROUPNAME_ERRORMESSAGE
  73. Dim L_ACCOUNTALREADYEXIST_ERRORMESSAGE
  74. Dim L_GROUPNAMEUPDATIONFAILED_ERRORMESSAGE
  75. L_GENERAL_TEXT = GetLocString("usermsg.dll", "&H4031000A", "")
  76. L_MEMBERS_TEXT = GetLocString("usermsg.dll", "&H40310002", "")
  77. L_GROUP_NAME_TEXT = GetLocString("usermsg.dll", "&H40310001", "")
  78. L_DESCRIPTION_TEXT = GetLocString("usermsg.dll", "&H40310030", "")
  79. L_MEMBERSPROMPT_TEXT = GetLocString("usermsg.dll", "&H40310042", "")
  80. L_ADDUSERORGROUP_TEXT = GetLocString("usermsg.dll", "&H40310006", "")
  81. L_ADD_TEXT = GetLocString("usermsg.dll", "&H40310003", "")
  82. L_REMOVE_TEXT = GetLocString("usermsg.dll", "&H40310004", "")
  83. L_DOMAINUSERHELP_TEXT = GetLocString("usermsg.dll", "&H4031000B", "")
  84. L_HOWTO_ADDDOMAINUSER = GetLocString("usermsg.dll", "403100C8", "")
  85. L_HOWTO_ENTERCREDENTIALS = GetLocString("usermsg.dll", "403100C9", "")
  86. L_USERNAME_PROMPT = GetLocString("usermsg.dll", "403100CA", "")
  87. L_PASSWORD_PROMPT = GetLocString("usermsg.dll", "403100CB", "")
  88. 'error messages
  89. L_GROUPPROPNOTOBTAINED_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310033", "")
  90. L_GROUPNOTPRESENT_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310011", "")
  91. L_GROUPNAMENOTVALID_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310014", "")
  92. L_INVALIDCHARACTER_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310015", "")
  93. L_LONGGRPDESCRIPTION_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310038", "")
  94. L_SELECTMEMBER_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031000D", "")
  95. L_DOMUSERINVALIDCHARACTER_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310019", "")
  96. L_DUPLICATEMEMBER_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031000C", "")
  97. L_INVALIDDOMAINUSER_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031001A", "")
  98. L_DESCRIPTIONUPDATEFAILED_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310037", "")
  99. L_USERNOTFOUND_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031001B", "")
  100. L_MEMBERUPDATIONFAILED_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310035", "")
  101. L_NONUNIQUEGROUPNAME_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031000E", "")
  102. L_ACCOUNTALREADYEXIST_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031000F", "")
  103. L_GROUPNAMEUPDATIONFAILED_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310036", "")
  104. Const N_ACCOUNTALREADYEXIST_ERRNO = &H800708B0
  105. Const N_NONUNIQUEGROUPNAME_ERRNO = &H80070563
  106. Const N_GROUPNOTPRESENT_ERRNO = &H8007056B
  107. ' Create a Tabbed Property Page
  108. Dim aGroup(0)
  109. Call OTS_GetTableSelectionCount("")
  110. Call OTS_GetTableSelection("", 1, G_strGroupName)
  111. Call SA_TraceOut(SA_GetScriptFileName, "Selected group: " + G_strGroupName)
  112. F_strGroupName=G_strGroupName
  113. aGroup(0) = G_strGroupName
  114. L_TASKTITLE_TEXT = GetLocString("usermsg.dll", "&H40310031", aGroup)
  115. rc = SA_CreatePage(L_TASKTITLE_TEXT, "", PT_TABBED, page )
  116. '
  117. ' Add two tabs
  118. rc = SA_AddTabPage( page, L_GENERAL_TEXT, idGeneralTab)
  119. rc = SA_AddTabPage( page, L_MEMBERS_TEXT, idMembersTab)
  120. '
  121. ' Show the page
  122. rc = SA_ShowPage( page )
  123. '======================================================
  124. ' Web Framework Event Handlers
  125. '======================================================
  126. '---------------------------------------------------------------------
  127. 'Function: OnInitPage()
  128. 'Description: Called to signal first time processing for this page.
  129. 'Input Variables: PageIn,EventArg
  130. 'Output Variables: None
  131. 'Returns: True/False
  132. 'Global Variables: G_objService,F_strGroupMembers,F_strGrpDescription,
  133. ' F_strCurrentGroupMembers
  134. '---------------------------------------------------------------------
  135. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  136. Set G_objService=GetWMIConnection("Default")
  137. F_strGrpDescription=getGrpDescription(F_strGroupName)
  138. F_strGroupMembers=getLocalUsersList(G_objService)
  139. F_strCurrentGroupMembers = getMembersofGroup(F_strGroupName)
  140. OnInitPage = TRUE
  141. End Function
  142. '---------------------------------------------------------------------
  143. 'Function: OnPostBackPage()
  144. 'Description: Called to signal that the page has been posted-back.
  145. 'Input Variables: PageIn,EventArg
  146. 'Output Variables: None
  147. 'Returns: True/False
  148. 'Global Variables: F_strGroupName,F_strGrpDescription,F_strCurrentGroupMembers,
  149. ' F_strOldGroupName,F_strOldGrpDescription,
  150. ' F_strGroupsAdded,F_strGroupsRemoved,F_strCredentialID,
  151. ' F_strCredentialPSW,F_strGroupMembers,G_objService
  152. '---------------------------------------------------------------------
  153. Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg)
  154. Set G_objService=GetWMIConnection("Default")
  155. F_strGroupName=Request.Form("txtGroupName")
  156. F_strGrpDescription=Request.Form ("txaGrpDescription")
  157. 'F_strCurrentGroupMembers = getMembersofGroup(G_strGroupName)
  158. F_strOldGroupName = Request.form("hdnGrpName")
  159. F_strOldGrpDescription = Request.form("hdnGrpDescription")
  160. F_strCurrentGroupMembers = Request.form("hdnGrpMembers")
  161. F_strGroupsAdded = Request.form("hdnGroupsAdded")
  162. F_strGroupsRemoved = Request.form("hdnGroupsRemoved")
  163. F_strCredentialID = Request.form("txtCredentialID")
  164. F_strCredentialPSW = Request.form("txtCredentialPSW")
  165. F_strGroupMembers=getLocalUsersList(G_objService)
  166. OnPostBackPage = TRUE
  167. End Function
  168. '---------------------------------------------------------------------
  169. 'Function: OnServeTabbedPropertyPage()
  170. 'Description: Called when the content needs to send
  171. 'Input Variables: PageIn,EventArg,iTab,bIsVisible
  172. 'Output Variables: None
  173. 'Returns: True/False
  174. 'Global Variables: iTab,idGeneralTab,idMembersTab
  175. '---------------------------------------------------------------------
  176. Public Function OnServeTabbedPropertyPage(ByRef PageIn, _
  177. ByVal iTab, _
  178. ByVal bIsVisible, ByRef EventArg)
  179. ' Emit Web Framework required functions
  180. If ( iTab = 0 ) Then
  181. Call ServeCommonJavaScript()
  182. End If
  183. '
  184. ' Emit content for the requested tab
  185. Select Case iTab
  186. Case idGeneralTab
  187. Call ServeTab1(PageIn, bIsVisible)
  188. Case idMembersTab
  189. Call ServeTab2(PageIn, bIsVisible)
  190. Case Else
  191. SA_TraceOut "GROUP_TABBED", _
  192. "OnServeTabbedPropertyPage unrecognized tab id: " + CStr(iTab)
  193. End Select
  194. OnServeTabbedPropertyPage = TRUE
  195. End Function
  196. '---------------------------------------------------------------------
  197. 'Function: OnSubmitPage()
  198. 'Description: Called when the page has been submitted for processing.
  199. 'Input Variables: PageIn,EventArg
  200. 'Output Variables: None
  201. 'Returns: True/False
  202. 'Global Variables: None
  203. '---------------------------------------------------------------------
  204. Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
  205. OnSubmitPage = setGroupProp()
  206. End Function
  207. '---------------------------------------------------------------------
  208. 'Function: OnClosePage()
  209. 'Description: Called when the page is about closed.
  210. 'Input Variables: PageIn,EventArg
  211. 'Output Variables: None
  212. 'Returns: True/False
  213. 'Global Variables: None
  214. '---------------------------------------------------------------------
  215. Public Function OnClosePage(ByRef PageIn, ByRef EventArg)
  216. OnClosePage = TRUE
  217. End Function
  218. '======================================================
  219. ' Private Functions
  220. '======================================================
  221. Function ServeTab1(ByRef PageIn, ByVal bIsVisible)
  222. If ( bIsVisible ) Then
  223. %>
  224. <TABLE WIDTH=518 VALIGN=middle ALIGN=left BORDER=0 CELLSPACING=0 CELLPADDING=2 class="TasksBody">
  225. <TR>
  226. <TD WIDTH=25% NOWRAP>
  227. <%=L_GROUP_NAME_TEXT %>
  228. </TD>
  229. <TD ALIGN="left" COLSPAN="2">
  230. <INPUT CLASS ="FormField" TYPE="text" NAME ="txtGroupName" STYLE="WIDTH:180px" VALUE="<%=Server.HTMLEncode(F_strGroupName)%>" MAXLENGTH="20" onKeyUp="CheckInput(txtGroupName)" onChange="CheckInput(txtGroupName)">
  231. </TD>
  232. </TR>
  233. <TR>
  234. <TD WIDTH=25% NOWRAP>
  235. <%=L_DESCRIPTION_TEXT %>
  236. </TD>
  237. <TD>
  238. <INPUT NAME="txaGrpDescription" TYPE="text" SIZE="40" onFocus="document.onkeypress=null" onBlur="document.onkeypress=HandleKeyPress" VALUE="<%=Server.HTMLEncode(F_strGrpDescription)%>" maxlength=256>
  239. </TD>
  240. </TR>
  241. </TABLE>
  242. <%
  243. Else
  244. %>
  245. <INPUT TYPE="HIDDEN" NAME ="txtGroupName" VALUE="<%=Server.HTMLEncode(F_strGroupName)%>" >
  246. <INPUT TYPE="HIDDEN" NAME="txaGrpDescription" VALUE="<%=Server.HTMLEncode(F_strGrpDescription)%>" >
  247. <INPUT TYPE="HIDDEN" NAME="hdnGrpMembers" VALUE="<%=Server.HTMLEncode(F_strCurrentGroupMembers)%>">
  248. <INPUT TYPE="HIDDEN" NAME="hdnGrpName" VALUE="<%=Server.HTMLEncode(F_strOldGroupName)%>">
  249. <INPUT TYPE="HIDDEN" NAME="hdnGrpDescription" VALUE="<%=Server.HTMLEncode(F_strOldGrpDescription)%>">
  250. <INPUT TYPE="HIDDEN" NAME="hdnGrpNameChanged" VALUE="0">
  251. <INPUT TYPE="HIDDEN" NAME="hdnGrpDescriptionChanged" VALUE="0">
  252. <INPUT TYPE="HIDDEN" NAME="hdnGroupsAdded" VALUE="<%=Server.HTMLEncode(F_strGroupsAdded)%>">
  253. <INPUT TYPE="HIDDEN" NAME="hdnGroupsRemoved" VALUE="<%=Server.HTMLEncode(F_strGroupsRemoved)%>">
  254. <%
  255. End If
  256. ServeTab1 = gc_ERR_SUCCESS
  257. End Function
  258. Function ServeTab2(ByRef PageIn, ByVal bIsVisible)
  259. Call ServeCommonJavaScript()
  260. If ( bIsVisible ) Then
  261. %>
  262. <TABLE WIDTH=300 VALIGN=middle xALIGN=left BORDER=0 CELLSPACING=0 CELLPADDING=2 class="TasksBody">
  263. <TR>
  264. <TD colspan=6>
  265. <% CheckForSecureSite %>
  266. </TD>
  267. </TR>
  268. <TR>
  269. <TD>
  270. &nbsp;&nbsp
  271. </TD>
  272. </TR>
  273. <TR>
  274. <TD nowrap width=190> <%=L_MEMBERSPROMPT_TEXT %> </TD>
  275. <TD> </TD>
  276. <TD> <%=L_ADDUSERORGROUP_TEXT %> </TD>
  277. </TR>
  278. <TR>
  279. <TD nowrap valign=top width=190>
  280. <SELECT class ="FormField" SIZE="9" NAME="lstCurrrentMembers" onChange="ClearErr()">
  281. <%
  282. ServetoListBox(F_strCurrentGroupMembers)
  283. %>
  284. </SELECT>
  285. </TD>
  286. <TD valign="center" align="center" width="110" HEIGHT="30px">
  287. <INPUT TYPE="button" class="TaskButtons" VALUE="<%=Server.HTMLEncode(L_ADD_TEXT)%>" NAME="btnAddMember" onClick="addMember();SetData()">
  288. <br>
  289. <INPUT TYPE="button" class="TaskButtons" VALUE="<%=Server.HTMLEncode(L_REMOVE_TEXT)%>" NAME="btnRemoveMember" onClick="removeMember();SetData()">
  290. </TD>
  291. <TD valign="top">
  292. <SELECT class ="FormField" SIZE="7" NAME="lstDomainMembers" onChange="ClearErr();document.frmTask.btnAddMember.disabled = false;" multiple>
  293. <%
  294. ServetoListBox(F_strGroupMembers)
  295. %>
  296. </SELECT>
  297. </TD>
  298. </TR>
  299. </TABLE>
  300. <p><%=L_DOMAINUSERHELP_TEXT%>
  301. <p><%=L_HOWTO_ADDDOMAINUSER%>
  302. <TABLE VALIGN=middle BORDER=0 CELLSPACING=0 CELLPADDING=2 class="TasksBody">
  303. <TR nowrap>
  304. <TD nowrap width=180><INPUT class ="FormField" TYPE = "text" STYLE="WIDTH:180px" Name ="txtDomainUser" onKeyUP ="disableAddButton(this,document.frmTask.btnAddDomainMember)"></TD>
  305. <TD><INPUT TYPE="button" class="TaskButtons" VALUE="<%=Server.HTMLEncode(L_ADD_TEXT)%>" NAME="btnAddDomainMember" onClick="addDomainMember(document.frmTask.txtDomainUser);SetData()"></TD>
  306. </TR>
  307. </TABLE>
  308. <br>
  309. <p><%=L_HOWTO_ENTERCREDENTIALS%>
  310. <TABLE VALIGN=middle BORDER=0 CELLSPACING=0 CELLPADDING=2 class="TasksBody">
  311. <TR>
  312. <TD><%=Server.HTMLEncode(L_USERNAME_PROMPT)%></TD>
  313. <TD><INPUT class ="FormField" TYPE = "text" STYLE="WIDTH:180px" Name ="txtCredentialID" value="<%=F_strCredentialID%>" ></TD>
  314. </TR>
  315. <TR>
  316. <TD><%=Server.HTMLEncode(L_PASSWORD_PROMPT)%></TD>
  317. <TD><INPUT class ="FormField" TYPE = "password" STYLE="WIDTH:180px" Name ="txtCredentialPSW" value="<%=F_strCredentialPSW%>"></TD>
  318. </TR>
  319. </TABLE>
  320. <%
  321. Else
  322. %>
  323. <INPUT TYPE="HIDDEN" NAME ="txtCredentialID" VALUE="<%=Server.HTMLEncode(F_strCredentialID)%>" >
  324. <INPUT TYPE="HIDDEN" NAME="txtCredentialPSW" VALUE="<%=Server.HTMLEncode(F_strCredentialPSW)%>" >
  325. <INPUT TYPE="HIDDEN" NAME="hdnGrpMembers" VALUE="<%=Server.HTMLEncode(F_strCurrentGroupMembers)%>">
  326. <INPUT TYPE="HIDDEN" NAME="hdnGrpName" VALUE="<%=Server.HTMLEncode(F_strOldGroupName)%>">
  327. <INPUT TYPE="HIDDEN" NAME="hdnGrpDescription" VALUE="<%=Server.HTMLEncode(F_strOldGrpDescription)%>">
  328. <INPUT TYPE="HIDDEN" NAME="hdnGrpNameChanged" VALUE="0">
  329. <INPUT TYPE="HIDDEN" NAME="hdnGrpDescriptionChanged" VALUE="0">
  330. <INPUT TYPE="HIDDEN" NAME="hdnGroupsAdded" VALUE="<%=Server.HTMLEncode(F_strGroupsAdded)%>">
  331. <INPUT TYPE="HIDDEN" NAME="hdnGroupsRemoved" VALUE="<%=Server.HTMLEncode(F_strGroupsRemoved)%>">
  332. <% End If
  333. ServeTab2 = gc_ERR_SUCCESS
  334. End Function
  335. '---------------------------------------------------------------------
  336. ' Function: ServeCommonJavaScript
  337. '
  338. ' Description: Common javascript functions that are required by the Web
  339. ' Framework.
  340. '
  341. '---------------------------------------------------------------------
  342. Function ServeCommonJavaScript()
  343. %>
  344. <script language="JavaScript" src="<%=m_VirtualRoot%>inc_global.js">
  345. </script>
  346. <script language="JavaScript">
  347. var objForm = eval("document.frmTask");
  348. var intSelTab = objForm.TabSelected.value;
  349. function Init()
  350. {
  351. var strReturnurl=location.href;
  352. var tempCnt=strReturnurl.indexOf("&ReturnURL=");
  353. var straction=strReturnurl.substring(0,tempCnt);
  354. objForm.action = straction;
  355. objForm.Method.value = "";
  356. if(intSelTab == '0')
  357. objForm.txtGroupName.focus();
  358. else
  359. {
  360. //Disable add and remove buttons when no domainmembers
  361. if(objForm.lstDomainMembers.length == 0 )
  362. {
  363. objForm.lstDomainMembers.disabled = true;
  364. objForm.btnAddMember.disabled = true;
  365. objForm.btnRemoveMember.disabled = true;
  366. }
  367. else
  368. {
  369. objForm.lstDomainMembers.options[0].selected = true;
  370. }
  371. //Disable remove button when no members were selected
  372. if (objForm.lstCurrrentMembers.length ==0)
  373. {
  374. objForm.btnRemoveMember.disabled=true;
  375. }
  376. else
  377. {
  378. objForm.lstCurrrentMembers.options[0].selected =true;
  379. objForm.btnRemoveMember.disabled =false;
  380. }
  381. disableAddButton(document.frmTask.txtDomainUser,document.frmTask.btnAddDomainMember);
  382. <% If ( G_CREDENTIAL_ERROR ) Then %>
  383. objForm.txtCredentialID.focus();
  384. <% End If %>
  385. }
  386. }
  387. function ValidatePage()
  388. {
  389. var strGroupName;
  390. var strErrmsg;
  391. strErrmsg ="";
  392. if(intSelTab == '0')
  393. {
  394. strGroupName = document.frmTask.txtGroupName.value;
  395. if (Trim(strGroupName) == "" || isAlldots(strGroupName))
  396. {
  397. strErrmsg = "<%=Server.HTMLEncode(L_GROUPNAMENOTVALID_ERRORMESSAGE)%>" +
  398. strGroupName + " <%=Server.HTMLEncode(L_INVALIDCHARACTER_ERRORMESSAGE)%>";
  399. SA_DisplayErr(strErrmsg);
  400. //if its general prop
  401. if(intSelTab == '0')
  402. {
  403. document.frmTask.txtGroupName.focus();
  404. document.frmTask.onkeypress = ClearErr;
  405. }
  406. return false;
  407. }
  408. // Checks for invalid key entry
  409. if(!isvalidchar("/[\/\*\?\"<>\|+=,;:\[\\]\\\\\]/",strGroupName))
  410. {
  411. strErrmsg = "<%=Server.HTMLEncode(L_GROUPNAMENOTVALID_ERRORMESSAGE)%>" +
  412. strGroupName + " <%=Server.HTMLEncode(L_INVALIDCHARACTER_ERRORMESSAGE)%>";
  413. SA_DisplayErr(strErrmsg);
  414. //if its general prop
  415. if(intSelTab == '0')
  416. {
  417. document.frmTask.txtGroupName.focus();
  418. document.frmTask.onkeypress = ClearErr;
  419. }
  420. return false;
  421. }
  422. //Checking for length of the description
  423. if(document.frmTask.txaGrpDescription.value.length > 256)
  424. {
  425. SA_DisplayErr("<% =Server.HTMLEncode(L_LONGGRPDESCRIPTION_ERRORMESSAGE) %>");
  426. //if its general prop
  427. if(intSelTab == '0')
  428. {
  429. document.frmTask.txaGrpDescription.focus();
  430. document.frmTask.onkeypress = ClearErr;
  431. }
  432. return false;
  433. }
  434. }
  435. return true;
  436. }
  437. function SetData()
  438. {
  439. var i;
  440. var strTemp;
  441. strTemp ="";
  442. //if its general prop
  443. if(intSelTab == '0')
  444. return true;
  445. for(i=0;i < objForm.lstCurrrentMembers.length ; i++)
  446. {
  447. strTemp = strTemp + String.fromCharCode(1) +objForm.lstCurrrentMembers.options[i].value
  448. +String.fromCharCode(2) +objForm.lstCurrrentMembers.options[i].text;
  449. }
  450. objForm.hdnGrpMembers.value =strTemp;
  451. }
  452. function addMember()
  453. {
  454. var strText;
  455. var objListBox;
  456. var strDomainName;
  457. var strRemovedGroups;
  458. var nIdx;
  459. objListBox = eval("document.frmTask.lstDomainMembers");
  460. if(objListBox.selectedIndex == -1)
  461. {
  462. SA_DisplayErr("<%=Server.HTMLEncode(L_SELECTMEMBER_ERRORMESSAGE)%>");
  463. document.frmTask.onkeypress = ClearErr;
  464. return false;
  465. }
  466. // code added for adding multiple entries into a list box
  467. for(nIdx =0 ; nIdx <objListBox.length ; nIdx++)
  468. {
  469. if(objListBox.options[nIdx].selected)
  470. {
  471. strText = objListBox.options[nIdx].text;
  472. strValue = objListBox.options[nIdx].value;
  473. if(addToListBox(objForm.lstCurrrentMembers,document.frmTask.btnRemoveMember,strText,strValue))
  474. {
  475. objForm.lstCurrrentMembers.disabled= false;
  476. strRemovedGroups = objForm.hdnGroupsRemoved.value;
  477. strRemovedGroups.toUpperCase().replace(( String.fromCharCode(1)+strValue.toUpperCase()),"");
  478. objForm.hdnGroupsRemoved.value = strRemovedGroups;
  479. objForm.hdnGroupsAdded.value = objForm.hdnGroupsAdded.value + String.fromCharCode(1) + strValue;
  480. }
  481. }
  482. }
  483. objListBox.selectedIndex = -1;
  484. document.frmTask.btnAddMember.disabled = true;
  485. }
  486. //Deletes the group member in the listbox
  487. function removeMember()
  488. {
  489. var strValue;
  490. var strAddedGroups;
  491. strValue = objForm.lstCurrrentMembers.options[objForm.lstCurrrentMembers.selectedIndex].value;
  492. strAddedGroups = objForm.hdnGroupsAdded.value;
  493. removeListBoxItems(objForm.lstCurrrentMembers,objForm.btnRemoveMember);
  494. strAddedGroups.toUpperCase().replace(( String.fromCharCode(1)+strValue.toUpperCase()),"");
  495. objForm.hdnGroupsAdded.value = strAddedGroups;
  496. objForm.hdnGroupsRemoved.value = objForm.hdnGroupsRemoved.value + String.fromCharCode(1) + strValue;
  497. }
  498. //Function to enable or disable OK button
  499. function CheckInput(objGrp)
  500. {
  501. if(objGrp.value !="")
  502. {
  503. EnableOK();
  504. }
  505. else {
  506. DisableOK();
  507. }
  508. }
  509. //Checks whether the given inputs has all dots or not
  510. function isAlldots(strInput)
  511. {
  512. var intIdx;
  513. for(intIdx=0;intIdx < strInput.length ; intIdx++)
  514. {
  515. if (strInput.charAt(intIdx) != ".")
  516. return false;
  517. }
  518. return true;
  519. }
  520. //Function to add a domain user
  521. function addDomainMember(objDomainUser)
  522. {
  523. var strText,strValue;
  524. var objListBox;
  525. objListBox = eval("document.frmTask.lstDomainMembers");
  526. // Checks For Invalid charecters in username
  527. if(!isvalidchar("/[\/\*\?\"<>\|+=,;:\[\\]\]/",objDomainUser.value))
  528. {
  529. SA_DisplayErr("<% =Server.HTMLEncode(L_DOMUSERINVALIDCHARACTER_ERRORMESSAGE) %>");
  530. document.frmTask.onkeypress = ClearErr;
  531. return false;
  532. }
  533. strText =objForm.txtDomainUser.value;
  534. strValue =objForm.txtDomainUser.value;
  535. //Checking for the domain\user format
  536. //if(!isvalidchar("/[^(\\\\| )]\\\\[^(\\\\| )]/",strText))
  537. if( strText.match( /[^(\\| )]{1,}\\[^(\\| )]{1,}/ ) )
  538. {
  539. if(!addToListBox(objForm.lstCurrrentMembers,objForm.btnAddDomainMember,strText,strValue))
  540. {
  541. SA_DisplayErr("<%=Server.HTMLEncode(L_DUPLICATEMEMBER_ERRORMESSAGE)%>");
  542. document.frmTask.onkeypress = ClearErr;
  543. return false;
  544. }
  545. objForm.txtDomainUser.value ="";
  546. objForm.btnAddDomainMember.disabled =true;
  547. if(objListBox.length != 0 )
  548. {
  549. objForm.btnRemoveMember.disabled = false;
  550. }
  551. strRemovedGroups = objForm.hdnGroupsRemoved.value;
  552. objForm.hdnGroupsRemoved.value = strRemovedGroups.replace(( String.fromCharCode(1)+strValue),"");
  553. if (objForm.hdnGroupsRemoved.value == strRemovedGroups )
  554. objForm.hdnGroupsAdded.value = objForm.hdnGroupsAdded.value +
  555. String.fromCharCode(1) + strValue;
  556. }
  557. else
  558. {
  559. SA_DisplayErr("<%=Server.HTMLEncode(L_INVALIDDOMAINUSER_ERRORMESSAGE)%>");
  560. document.frmTask.onkeypress = ClearErr;
  561. }
  562. }
  563. </script>
  564. <%
  565. End Function
  566. '-------------------------------------------------------------------------
  567. 'Function name: SetGroupProp
  568. 'Desription: Sets the group properties.
  569. 'Input Variables: None
  570. 'Output variables: True on succesful setting else False.
  571. 'Global Variables: In:G_objService
  572. ' In:G_strGroupName
  573. ' In:G_CREDENTIAL_ERROR
  574. ' In:F_(*)-Form vairables
  575. ' In:L_(*)-Localized strings
  576. '-------------------------------------------------------------------------
  577. Function SetGroupProp()
  578. Err.Clear
  579. On Error Resume Next
  580. Dim objComputer
  581. Dim objGroup
  582. Dim arrUserNames
  583. Dim i,j
  584. Dim intLoopCount
  585. Dim strCompName
  586. Dim strPath
  587. Dim strAdsPath
  588. Dim strDomain
  589. Dim objDummy
  590. Dim strPathConcat
  591. Dim strUserName
  592. Dim pos
  593. Dim strNTAuthorityDomainName
  594. ' Get localized domain names
  595. strNTAuthorityDomainName = getNTAuthorityDomainName(G_objService)
  596. G_CREDENTIAL_ERROR = FALSE
  597. 'Initialize the values to the computer name & domain name
  598. strCompName= GetComputerName()
  599. strPath = "Domain="""& strCompName &""",Name="""&F_strGroupName&""""
  600. strDomain = getConnectedDomain(G_objService)
  601. 'Get the ADSI computer object
  602. Set objComputer = GetObject("WinNT://" & strCompName )
  603. 'Get the current members in the group
  604. if strDomain <> "" then
  605. F_strCurrentGroupMembers = replace(F_strCurrentGroupMembers,chr(1)&strCompName ,chr(1)&strDomain & "\"&strCompName)
  606. F_strGroupsAdded = replace(F_strGroupsAdded,chr(1)& strCompName ,chr(1)&strDomain & "\"&strCompName)
  607. F_strGroupsRemoved = replace(F_strGroupsRemoved,chr(1)&strCompName ,chr(1)&strDomain & "\"&strCompName)
  608. end if
  609. 'Replace "\" and "/"
  610. F_strCurrentGroupMembers = replace(F_strCurrentGroupMembers,"\","/")
  611. F_strGroupsAdded = replace(F_strGroupsAdded,"\","/")
  612. F_strGroupsRemoved = replace(F_strGroupsRemoved,"\","/")
  613. 'Get the group object of the computer
  614. set objGroup = GetObject("WinNT://" & strCompName & "/" & G_strGroupName)
  615. 'Change the description
  616. objDummy = objGroup.Put("Description",F_strGrpDescription)
  617. 'Error handling
  618. If Err.number <> 0 Then
  619. SetErrMsg L_DESCRIPTIONUPDATEFAILED_ERRORMESSAGE
  620. 'Showing the general prop page
  621. mintTabSelected = 0
  622. SetGroupProp=FALSE
  623. Exit Function
  624. End If
  625. 'Groups to be added
  626. arrUserNames=split(F_strGroupsAdded,chr(1))
  627. intLoopCount=Ubound(arrUserNames)
  628. If strDomain <> "" Then
  629. strPathConcat = ucase(strDomain)&"/"& ucase(strCompName) &"/"
  630. Else
  631. strPathConcat = ucase(strCompName) &"/"
  632. End If
  633. 'Looping for each user in the selected List
  634. For i=1 To intLoopCount
  635. strUserName = arrUserNames(i)
  636. 'SA_TraceOut "GROUP_PROP", "Adding user: " + strUserName
  637. if instr(ucase(arrUserNames(i)) ,strPathConcat) <> 1 then
  638. If instr(ucase(arrUserNames(i)), strNTAuthorityDomainName) then
  639. pos = instr(ucase(arrUserNames(i)), "/")
  640. strUserName = Right(arrUserNames(i), len(arrUserNames(i)) - pos)
  641. End If
  642. Dim errorCode
  643. If Instr(strUserName,"/") then
  644. If isValidMember(strUserName, F_strCredentialID, F_strCredentialPSW, errorCode) = false then
  645. If (errorCode = GC_ERR_ACCESS_DENIED ) Then
  646. Dim aParam(1)
  647. Dim arg
  648. Dim L_CREDENTIALS_ERROR
  649. aParam(0) = replace(arrUserNames(i),"/","\")
  650. arg = aParam
  651. L_CREDENTIALS_ERROR = GetLocString( "usermsg.dll", "C03100CC", arg)
  652. SetErrMsg L_CREDENTIALS_ERROR
  653. G_CREDENTIAL_ERROR = TRUE
  654. Else
  655. SetErrMsg L_USERNOTFOUND_ERRORMESSAGE & replace(arrUserNames(i),"/","\") & " (" & Hex(errorCode) & ")"
  656. End If
  657. SA_TraceOut "GROUP_PROP", "IsValidMember("+strUserName+") failed: " +CStr(Hex(errorCode))
  658. 'Replace "\" with "/"
  659. F_strGroupsAdded = replace(F_strGroupsAdded,"/","\")
  660. F_strGroupsRemoved = replace(F_strGroupsRemoved,"/","\")
  661. F_strCurrentGroupMembers = replace(F_strCurrentGroupMembers,"/","\")
  662. 'Showing the general prop page
  663. mintTabSelected = 1
  664. SetGroupProp=FALSE
  665. Exit Function
  666. End If
  667. End if
  668. End If
  669. If ( Len(Trim(F_strCredentialID)) > 0 ) Then
  670. Call AddUserToGroup( G_strGroupName, strUserName, F_strCredentialID, F_strCredentialPSW )
  671. If ( Err.Number <> 0 ) Then
  672. Exit For
  673. End If
  674. Else
  675. strAdsPath="WinNT://" & strUserName
  676. objGroup.add(strAdsPath)
  677. End If
  678. strUserName = ""
  679. Next
  680. 'Groups to be removed
  681. arrUserNames=split(F_strGroupsRemoved,chr(1))
  682. intLoopCount=Ubound(arrUserNames)
  683. 'Looping for each user in the selected List
  684. For i=1 To intLoopCount
  685. strAdsPath="WinNT://" & arrUserNames(i)
  686. objGroup.remove(strAdsPath)
  687. Next
  688. 'Error handling
  689. If Err.number <> 0 Then
  690. 'checking for user existence
  691. If Err.number = N_GROUPNOTPRESENT_ERRNO Then
  692. SetErrMsg L_GROUPNOTPRESENT_ERRORMESSAGE
  693. F_strGroupsAdded = replace(F_strGroupsAdded,"/","\")
  694. F_strGroupsRemoved = replace(F_strGroupsRemoved,"/","\")
  695. F_strCurrentGroupMembers = replace(F_strCurrentGroupMembers,"/","\")
  696. 'Showing the general prop page
  697. mintTabSelected = 0
  698. Else
  699. ServeFailurePage L_MEMBERUPDATIONFAILED_ERRORMESSAGE
  700. End If
  701. SetGroupProp=FALSE
  702. Exit Function
  703. End If
  704. 'Set the info
  705. objGroup.setInfo()
  706. 'This is to change the Group name if required
  707. If ( F_strGroupname <> G_strGroupName ) Then
  708. 'Change the name of the group
  709. objComputer.MoveHere objGroup.AdsPath ,F_strGroupname
  710. 'Returning the path to the area page.
  711. If (instr(mstrReturnURL,"&PKey=") > 0) then
  712. mstrReturnURL = Left(mstrReturnURL,(instr(mstrReturnURL,"&PKey=")-1))
  713. End If
  714. mstrReturnURL=mstrReturnURL &"&PKey="&server.URLEncode(F_strGroupname)
  715. End If
  716. ' Set to Nothing
  717. Set objComputer =Nothing
  718. set objGroup =Nothing
  719. 'Error handling
  720. If Err.number <> 0 Then
  721. 'checking for group existence
  722. If Err.number = N_NONUNIQUEGROUPNAME_ERRNO Then
  723. SetErrMsg L_NONUNIQUEGROUPNAME_ERRORMESSAGE
  724. 'Showing the general prop page
  725. mintTabSelected = 0
  726. Else
  727. If Err.number= N_ACCOUNTALREADYEXIST_ERRNO Then
  728. SetErrMsg L_ACCOUNTALREADYEXIST_ERRORMESSAGE
  729. 'Showing the general prop page
  730. mintTabSelected = 0
  731. Else
  732. SetErrMsg L_GROUPNAMEUPDATIONFAILED_ERRORMESSAGE
  733. End If
  734. End If
  735. F_strGroupsAdded = replace(F_strGroupsAdded,"/","\")
  736. F_strGroupsRemoved = replace(F_strGroupsRemoved,"/","\")
  737. F_strCurrentGroupMembers = replace(F_strCurrentGroupMembers,"/","\")
  738. SetGroupProp=FALSE
  739. Exit Function
  740. End If
  741. SetGroupProp=TRUE
  742. End Function
  743. '-------------------------------------------------------------------------
  744. 'Function name: getGrpDescription
  745. 'Desription: Gets the dsecription for the group
  746. 'Input Variables: Group name
  747. 'Output variables: None
  748. 'Returns: The description for that group.
  749. 'Global Variables: In:L_(*) -Localized strings
  750. '-------------------------------------------------------------------------
  751. Function getGrpDescription(strGroupName)
  752. Dim strCompName
  753. Dim objGroup
  754. 'Get the computer name
  755. strCompName = GetComputerName()
  756. 'Get the group object
  757. Set objGroup = GetObject("WinNT://" & strCompName &"/"& strGroupName)
  758. 'Get the description for the group
  759. getGrpDescription = objGroup.Description
  760. if Err.number <> 0 then
  761. ServeFailurePage L_GROUPPROPNOTOBTAINED_ERRORMESSAGE
  762. End if
  763. End Function
  764. '-------------------------------------------------------------------------
  765. 'Function name: getMembersofGroup
  766. 'Desription: gets the Members of Groups
  767. 'Input Variables: strGroupName
  768. 'Output Variables: None
  769. 'Returns: Returns a string containing the members of the
  770. ' groups as chr(1) separated values
  771. 'Global Variables: In:L_(*)-Localized strings
  772. '-------------------------------------------------------------------------
  773. Function getMembersofGroup(strGroupName)
  774. Err.Clear
  775. On Error Resume Next
  776. Dim strCompName
  777. Dim objGrpMember
  778. Dim objGroup
  779. Dim strDomain
  780. Dim strTemp
  781. Dim strMembers
  782. Dim strReplace
  783. Dim strNTAuthorityDomainName
  784. Dim strBuiltinDomainName
  785. ' Get localized domain names
  786. strNTAuthorityDomainName = getNTAuthorityDomainName(G_objService)
  787. strBuiltinDomainName = getBuiltinDomainName(G_objService)
  788. strCompName = GetComputerName()
  789. strDomain = getConnectedDomain(G_objService)
  790. strMembers = ""
  791. 'Check whether the machine is in the domain or not
  792. if Trim(strDomain) <> "" then
  793. Set objGroup = GetObject("WinNT://" & strDomain & "/" & strCompName &"/"& strGroupName)
  794. else
  795. Set objGroup = GetObject("WinNT://" & strCompName &"/"& strGroupName)
  796. End if
  797. if Err.number <> 0 then
  798. ServeFailurePage L_GROUPNOTPRESENT_ERRORMESSAGE,"../groups.asp?tab1=TabUsersAndGroups&tab2=TabUsersAndGroupsGroups"
  799. End If
  800. Dim str1
  801. 'Loop through all the members of the group
  802. For each objGrpMember in objGroup.members
  803. 'Get the member in the domain/member format
  804. strTemp = getADSPath(objGrpMember.AdsPath)
  805. if instr(strTemp,"/") > 0 then
  806. 'strReplace = replace(strTemp,"BUILTIN/",strCompName&"/")
  807. strReplace = replace(strTemp, strBuiltinDomainName & "/","")
  808. If strReplace <> strTemp then
  809. strTemp = strTemp & chr(2) & strReplace
  810. else
  811. 'strTemp = strTemp & chr(2) & replace(strTemp,"NT AUTHORITY/",strCompName&"/")
  812. str1 = replace(strTemp,strNTAuthorityDomainName & "/","")
  813. 'strTemp = strTemp & chr(2) & replace(strTemp,"NT AUTHORITY/","")
  814. strTemp = strTemp & chr(2) & replace(str1,strCompName&"/","")
  815. End if
  816. else
  817. strTemp = strTemp & chr(2) & strTemp
  818. End if
  819. 'Concatinate the members
  820. strMembers = strMembers & chr(1) & strTemp
  821. next
  822. if Err.number <> 0 then
  823. ServeFailurePage L_GROUPPROPNOTOBTAINED_ERRORMESSAGE
  824. End if
  825. 'strMembers = replace(strMembers,strCompName & "/","")
  826. strMembers = replace(strMembers,"/","\")
  827. getMembersofGroup = strMembers
  828. End Function
  829. '-------------------------------------------------------------------------
  830. 'Function name: getADSPath
  831. 'Desription: Gets the member in Domain/Membername this form
  832. 'Input Variables: strGroupName
  833. 'Output Variables: None
  834. 'Returns: Member in the req. form
  835. 'Global Variables: In:L_(*) -Localized strings
  836. '-------------------------------------------------------------------------
  837. Function getADSPath(strADSIPath)
  838. Err.Clear
  839. on Error resume next
  840. Dim strPath
  841. Dim objRegEx
  842. Dim objMatchesCollection
  843. Dim objMatch
  844. 'Create the regular expression object
  845. set objRegEx = New RegExp
  846. if Err.number <> 0 then
  847. ServeFailurePage L_OBJECTCREATIONFAILED_ERRORMESSAGE
  848. End if
  849. 'Find the values globally
  850. objRegEx.Global = true
  851. 'Ignore the case
  852. objRegEx.ignorecase = true
  853. 'Pattern is X/Y or ://X
  854. objRegEx.Pattern = "[^/]+/[^/]+$|://[^/]+$"
  855. 'Get all the matches of the pattern
  856. set objMatchesCollection = objRegEx.Execute(strADSIPath)
  857. for each objMatch in objMatchesCollection
  858. 'For each match get the value
  859. strPath = objMatch.value
  860. strPath = replace(strPath,"://","")
  861. next
  862. 'Set the return value to the last match found
  863. getADSPath = strPath
  864. End Function
  865. %>