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.

805 lines
26 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' group_new.asp: Serves in creating a new group
  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 G_objService 'To get WMI connection
  21. Dim G_CREDENTIAL_ERROR 'Error constant
  22. Dim rc 'Return value for CreatePage
  23. Dim page 'Variable that receives the output page object when
  24. 'creating a page
  25. Dim idTabGeneral 'Variable for General tab
  26. Dim idTabMembers 'Variable for Members tab
  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 'Members of the group
  34. Dim F_strCurrentGroupMembers 'Current members of the group
  35. Dim F_strCredentialID 'Credential ID
  36. Dim F_strCredentialPSW 'Credential Password
  37. Const N_ACCOUNTALREADYEXIST_ERRNO = &H800708B0
  38. Const N_NONUNIQUEGROUPNAME_ERRNO = &H80070563
  39. Const N_GROUPNOTPRESENT_ERRNO = &H8007056B
  40. '-------------------------------------------------------------------------
  41. 'Start of localization content
  42. '-------------------------------------------------------------------------
  43. Dim L_GROUP_NAME_TEXT
  44. Dim L_DESCRIPTION_TEXT
  45. Dim L_MEMBERS_TEXT
  46. Dim L_ADD_TEXT
  47. Dim L_REMOVE_TEXT
  48. Dim L_PAGETITLE_GROUPNEW_TEXT
  49. Dim L_ADDUSERORGROUP_TEXT
  50. Dim L_NOINPUTDATA_TEXT
  51. Dim L_TABPROPSHEET_TEXT
  52. Dim L_DOMAINUSERHELP_TEXT
  53. Dim L_MEMBERSPROMPT_TEXT
  54. Dim L_HOWTO_ADDDOMAINUSER_TEXT
  55. Dim L_HOWTO_ENTERCREDENTIALS_TEXT
  56. Dim L_USERNAME_PROMPT_TEXT
  57. Dim L_PASSWORD_PROMPT_TEXT
  58. Dim L_DUPLICATEMEMBER_ERRORMESSAGE
  59. Dim L_SELECTMEMBER_ERRORMESSAGE
  60. Dim L_NONUNIQUEGROUPNAME_ERRORMESSAGE
  61. Dim L_ACCOUNTALREADYEXIST_ERRORMESSAGE
  62. Dim L_GROUPNOTCREATED_ERRORMESSAGE
  63. Dim L_GROUPNOTPRESENT_ERRORMESSAGE
  64. Dim L_GROUPPROPERTIESNOTSET_ERRORMESSAGE
  65. Dim L_MEMBERADDITIONFAILED_ERRORMESSAGE
  66. Dim L_GROUPNAMENOTVALID_ERRORMESSAGE
  67. Dim L_INVALIDCHARACTER_ERRORMESSAGE
  68. Dim L_LOCALIZATIONOBJECTFAILED_ERRORMESSAGE
  69. Dim L_COMPUTERNAME_ERRORMESSAGE
  70. Dim L_DOMUSERINVALIDCHARACTER_ERRORMESSAGE
  71. Dim L_USERNOTFOUND_ERRORMESSAGE
  72. Dim L_INVALIDDOMAINUSER_ERRORMESSAGE
  73. Dim L_LONGGRPDESCRIPTION_ERRORMESSAGE
  74. Dim L_CREDENTIALS_ERRORMESSAGE
  75. Dim L_GENERAL_TEXT
  76. L_GENERAL_TEXT = GetLocString("usermsg.dll", "&H4031000A", "")
  77. L_HOWTO_ADDDOMAINUSER_TEXT = GetLocString("usermsg.dll", "403100C8", "")
  78. L_HOWTO_ENTERCREDENTIALS_TEXT = GetLocString("usermsg.dll", "403100C9", "")
  79. L_USERNAME_PROMPT_TEXT = GetLocString("usermsg.dll", "403100CA", "")
  80. L_PASSWORD_PROMPT_TEXT = GetLocString("usermsg.dll", "403100CB", "")
  81. L_GROUP_NAME_TEXT = GetLocString("usermsg.dll", "&H40310001", "")
  82. L_DESCRIPTION_TEXT = GetLocString("usermsg.dll", "&H40310030", "")
  83. L_MEMBERS_TEXT = GetLocString("usermsg.dll", "&H40310002", "")
  84. L_ADD_TEXT = GetLocString("usermsg.dll", "&H40310003", "")
  85. L_REMOVE_TEXT = GetLocString("usermsg.dll", "&H40310004", "")
  86. L_PAGETITLE_GROUPNEW_TEXT = GetLocString("usermsg.dll", "&H40310005", "")
  87. L_ADDUSERORGROUP_TEXT = GetLocString("usermsg.dll", "&H40310006", "")
  88. L_NOINPUTDATA_TEXT = GetLocString("usermsg.dll", "&H40310007", "")
  89. L_TABPROPSHEET_TEXT = GetLocString("usermsg.dll", "&H40310008", "")
  90. L_DOMAINUSERHELP_TEXT = GetLocString("usermsg.dll", "&H4031000B", "")
  91. L_MEMBERSPROMPT_TEXT = GetLocString("usermsg.dll", "&H40310042", "")
  92. 'Error Messages
  93. L_DUPLICATEMEMBER_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031000C", "")
  94. L_SELECTMEMBER_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031000D", "")
  95. L_NONUNIQUEGROUPNAME_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031000E", "")
  96. L_ACCOUNTALREADYEXIST_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031000F", "")
  97. L_GROUPNOTCREATED_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310010", "")
  98. L_GROUPNOTPRESENT_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310011", "")
  99. L_GROUPPROPERTIESNOTSET_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310012", "")
  100. L_MEMBERADDITIONFAILED_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310013", "")
  101. L_GROUPNAMENOTVALID_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310014", "")
  102. L_INVALIDCHARACTER_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310015", "")
  103. L_LOCALIZATIONOBJECTFAILED_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310017", "")
  104. L_COMPUTERNAME_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310018", "")
  105. L_DOMUSERINVALIDCHARACTER_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310019", "")
  106. L_USERNOTFOUND_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031001B", "")
  107. L_INVALIDDOMAINUSER_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031001A", "")
  108. L_LONGGRPDESCRIPTION_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310038", "")
  109. '-------------------------------------------------------------------------
  110. ' END of localization content
  111. '-------------------------------------------------------------------------
  112. '
  113. 'Create a Tabbed Property Page
  114. rc = SA_CreatePage( L_PAGETITLE_GROUPNEW_TEXT , "", PT_TABBED, page )
  115. '
  116. 'Add two tabs
  117. rc = SA_AddTabPage( page, L_GENERAL_TEXT, idTabGeneral)
  118. rc = SA_AddTabPage( page, L_MEMBERS_TEXT, idTabMembers)
  119. '
  120. 'Show the page
  121. rc = SA_ShowPage( page )
  122. '---------------------------------------------------------------------
  123. 'Function: OnInitPage()
  124. 'Description: Called to signal first time processing for this page.
  125. 'Input Variables: PageIn,EventArg
  126. 'Output Variables: None
  127. 'Returns: True/False
  128. 'Global Variables: G_objService,F_strGroupMembers,L_WMI_CONNECTIONFAIL_ERRORMESSAGE
  129. '---------------------------------------------------------------------
  130. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  131. OnInitPage = TRUE
  132. 'Connecting to the server
  133. Set G_objService=GetWMIConnection("Default")
  134. If Err.number <> 0 Then
  135. ServeFailurePage L_WMI_CONNECTIONFAIL_ERRORMESSAGE,1
  136. End if
  137. 'Get the members of the domain & computer
  138. F_strGroupMembers = getLocalUsersList(G_objService)
  139. End Function
  140. '---------------------------------------------------------------------
  141. 'Function: OnPostBackPage()
  142. 'Description: Called to signal that the page has been posted-back.
  143. 'Input Variables: PageIn,EventArg
  144. 'Output Variables: None
  145. 'Returns: True/False
  146. 'Global Variables: F_(*),G_objService,L_WMI_CONNECTIONFAIL_ERRORMESSAGE
  147. '---------------------------------------------------------------------
  148. Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg)
  149. F_strGroupName = Request.form("txtGroupName")
  150. F_strGrpDescription = Request.form("txaGrpDescription")
  151. F_strCurrentGroupMembers = Request.form("hdnGrpMembers")
  152. F_strCredentialID = Request.form("txtCredentialID")
  153. F_strCredentialPSW = Request.form("txtCredentialPSW")
  154. 'Connecting to the server
  155. Set G_objService=GetWMIConnection("Default")
  156. If Err.number <> 0 Then
  157. ServeFailurePage L_WMI_CONNECTIONFAIL_ERRORMESSAGE,1
  158. End if
  159. F_strGroupMembers = getLocalUsersList(G_objService)
  160. OnPostBackPage = True
  161. End Function
  162. '---------------------------------------------------------------------
  163. 'Function: OnServeTabbedPropertyPage()
  164. 'Description: Called when the content needs to send
  165. 'Input Variables: PageIn,EventArg,iTab,bIsVisible
  166. 'Output Variables: None
  167. 'Returns: True/False
  168. 'Global Variables: iTab
  169. '---------------------------------------------------------------------
  170. Public Function OnServeTabbedPropertyPage(ByRef PageIn, _
  171. ByVal iTab, _
  172. ByVal bIsVisible, ByRef EventArg)
  173. '
  174. ' Emit Web Framework required functions
  175. If ( iTab = 0 ) Then
  176. Call ServeCommonJavaScript()
  177. End If
  178. '
  179. ' Emit content for the requested tab
  180. Select Case iTab
  181. Case idTabGeneral
  182. Call ServeTabGeneral(PageIn, bIsVisible)
  183. Case idTabMembers
  184. Call ServeTabMembers(PageIn, bIsVisible)
  185. Case Else
  186. SA_TraceOut "TEMPLAGE_TABBED", _
  187. "OnServeTabbedPropertyPage unrecognized tab id: " + CStr(iTab)
  188. End Select
  189. OnServeTabbedPropertyPage = TRUE
  190. End Function
  191. '---------------------------------------------------------------------
  192. 'Function: OnSubmitPage()
  193. 'Description: Called when the page has been submitted for processing.
  194. 'Input Variables: PageIn,EventArg
  195. 'Output Variables: None
  196. 'Returns: True/False
  197. 'Global Variables: None
  198. '---------------------------------------------------------------------
  199. Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
  200. 'Create new group on submitting the page
  201. OnSubmitPage = CreateNewGroup()
  202. End Function
  203. '---------------------------------------------------------------------
  204. 'Function: OnClosePage()
  205. 'Description: Called when the page is about closed.
  206. 'Input Variables: PageIn,EventArg
  207. 'Output Variables: None
  208. 'Returns: True/False
  209. 'Global Variables: None
  210. '---------------------------------------------------------------------
  211. Public Function OnClosePage(ByRef PageIn, ByRef EventArg)
  212. OnClosePage = TRUE
  213. End Function
  214. '-------------------------------------------------------------------------
  215. 'Function: ServeTabGeneral()
  216. 'Description: For displaying outputs HTML for tab 1 to the user
  217. 'Input Variables: PageIn,bIsVisible
  218. 'Output Variables: None
  219. 'Returns: gc_ERR_SUCCESS
  220. 'Global Variables: F_strGroupName,F_strGrpDescription,F_strCurrentGroupMembers,L_(*)
  221. '-------------------------------------------------------------------------
  222. Function ServeTabGeneral(ByRef PageIn, ByVal bIsVisible)
  223. If (bIsVisible) Then
  224. %>
  225. <TABLE WIDTH=518 VALIGN=middle ALIGN=left BORDER=0 CELLSPACING=0
  226. CELLPADDING=2 class="TasksBody">
  227. <TR>
  228. <TD width=25% NOWRAP>
  229. <%=L_GROUP_NAME_TEXT %>
  230. </TD>
  231. <TD align="left" colspan="2">
  232. <INPUT class ="FormField" TYPE="text" NAME ="txtGroupName" STYLE="WIDTH:180px" VALUE="<%=Server.HTMLEncode(F_strGroupName)%>" MAXLENGTH="20" onKeyUp="CheckInput(txtGroupName)" onChange="CheckInput(txtGroupName)">
  233. </TD>
  234. </TR>
  235. <TR>
  236. <TD width=25% NOWRAP>
  237. <%=L_DESCRIPTION_TEXT %>
  238. </TD>
  239. <TD>
  240. <input NAME="txaGrpDescription" TYPE="text" SIZE="40" onFocus="document.onkeypress=null" onBlur="document.onkeypress=HandleKeyPress" VALUE="<%=server.htmlencode(F_strGrpDescription)%>" maxlength=300>
  241. </TD>
  242. </TABLE>
  243. <%
  244. Else
  245. %>
  246. <INPUT TYPE="HIDDEN" NAME="hdnGrpMembers" VALUE="<%=Server.HTMLEncode(F_strCurrentGroupMembers)%>">
  247. <INPUT TYPE="HIDDEN" NAME ="txtGroupName" VALUE="<%=Server.HTMLEncode(F_strGroupName)%>" >
  248. <INPUT TYPE="HIDDEN" NAME="txaGrpDescription" value="<%=Server.HTMLEncode(F_strGrpDescription)%>" >
  249. <%
  250. End If
  251. ServeTabGeneral = gc_ERR_SUCCESS
  252. End Function
  253. '-------------------------------------------------------------------------
  254. 'Function: ServeTabMembers()
  255. 'Description: For displaying outputs HTML for tab 2 to the user
  256. 'Input Variables: PageIn,bIsVisible
  257. 'Output Variables: None
  258. 'Returns: gc_ERR_SUCCESS
  259. 'Global Variables: L_(*)
  260. '-------------------------------------------------------------------------
  261. Function ServeTabMembers(ByRef PageIn, ByVal bIsVisible)
  262. Call ServeCommonJavaScript()
  263. If (bIsVisible) Then
  264. %>
  265. <TABLE WIDTH=300 VALIGN=middle BORDER=0 CELLSPACING=0 CELLPADDING=2 class="TasksBody">
  266. <TR>
  267. <TD colspan=6>
  268. <% CheckForSecureSite %>
  269. </TD>
  270. </TR>
  271. <TR>
  272. <TD>
  273. &nbsp;&nbsp
  274. </TD>
  275. </TR>
  276. <TR>
  277. <TD nowrap width=190><%=L_MEMBERSPROMPT_TEXT %></TD>
  278. <TD> </TD>
  279. <TD> <%=L_ADDUSERORGROUP_TEXT %> </TD>
  280. </TR>
  281. <TR>
  282. <TD nowrap valign=top width=190>
  283. <SELECT class ="FormField" SIZE="9" NAME="lstCurrrentMembers" onChange="ClearErr()">
  284. <%
  285. ServetoListBox(F_strCurrentGroupMembers)
  286. %>
  287. </SELECT>
  288. </TD>
  289. <TD valign="center" align="center" width="110" HEIGHT="30px">
  290. <INPUT TYPE="button" class="TaskButtons" VALUE="<%=Server.HTMLEncode(L_ADD_TEXT)%>" NAME="btnAddMember" onClick="addMember();SetData()">
  291. <BR>
  292. <INPUT TYPE="button" class="TaskButtons" VALUE="<%=Server.HTMLEncode(L_REMOVE_TEXT)%>" NAME="btnRemoveMember" onClick="removeMember();SetData()">
  293. </TD>
  294. <TD valign="top">
  295. <SELECT class ="FormField" SIZE="7" NAME="lstDomainMembers" onChange="ClearErr();document.frmTask.btnAddMember.disabled = false;" multiple>
  296. <%
  297. ServetoListBox(F_strGroupMembers)
  298. %>
  299. </SELECT>
  300. </TD>
  301. </TR>
  302. </TABLE>
  303. <p><%=L_DOMAINUSERHELP_TEXT%>
  304. <p><%=L_HOWTO_ADDDOMAINUSER_TEXT%>
  305. <TABLE VALIGN=middle BORDER=0 CELLSPACING=0 CELLPADDING=2 class="TasksBody">
  306. <TR nowrap>
  307. <TD nowrap width=180><INPUT class ="FormField" TYPE = "text" STYLE="WIDTH:180px" Name ="txtDomainUser" onKeyUP ="disableAddButton(this,document.frmTask.btnAddDomainMember)"></TD>
  308. <TD><INPUT TYPE="button" class="TaskButtons" VALUE="<%=Server.HTMLEncode(L_ADD_TEXT)%>" NAME="btnAddDomainMember" onClick="addDomainMember(document.frmTask.txtDomainUser);SetData()"></TD>
  309. </TR>
  310. </TABLE>
  311. <br>
  312. <p><%=L_HOWTO_ENTERCREDENTIALS_TEXT%>
  313. <TABLE VALIGN=middle BORDER=0 CELLSPACING=0 CELLPADDING=2 class="TasksBody">
  314. <TR>
  315. <TD><%=Server.HTMLEncode(L_USERNAME_PROMPT_TEXT)%></TD>
  316. <TD><INPUT class ="FormField" TYPE = "text" STYLE="WIDTH:180px" Name ="txtCredentialID" value="<%=F_strCredentialID%>" ></TD>
  317. </TR>
  318. <TR>
  319. <TD><%=Server.HTMLEncode(L_PASSWORD_PROMPT_TEXT)%></TD>
  320. <TD><INPUT class ="FormField" TYPE = "password" STYLE="WIDTH:180px" Name ="txtCredentialPSW" value="<%=F_strCredentialPSW%>"></TD>
  321. </TR>
  322. </TABLE>
  323. <%
  324. Else
  325. %>
  326. <INPUT TYPE="HIDDEN" NAME="hdnGrpMembers" VALUE="<%=Server.HTMLEncode(F_strCurrentGroupMembers)%>">
  327. <INPUT TYPE="HIDDEN" NAME ="txtCredentialID" VALUE="<%=Server.HTMLEncode(F_strCredentialID)%>" >
  328. <INPUT TYPE="HIDDEN" NAME="txtCredentialPSW" VALUE="<%=Server.HTMLEncode(F_strCredentialPSW)%>" >
  329. <%
  330. End If
  331. ServeTabMembers = gc_ERR_SUCCESS
  332. End Function
  333. '-------------------------------------------------------------------------
  334. 'Function: ServeCommonJavaScript
  335. 'Description: Serves in initialiging the values,setting the form
  336. ' data and validating the form values
  337. 'Input Variables: None
  338. 'Output Variables: None
  339. 'Returns: True/False
  340. 'Global Variables: In-F_(*) -All form variables
  341. ' In-L_(*)-Localization variables
  342. '-------------------------------------------------------------------------
  343. Function ServeCommonJavaScript()
  344. %>
  345. <script language="JavaScript" src="<%=m_VirtualRoot%>inc_global.js">
  346. </script>
  347. <script language="JavaScript">
  348. // Set the initial form values
  349. var objForm = eval("document.frmTask")
  350. var intSelTab = objForm.TabSelected.value
  351. function Init()
  352. {
  353. var strReturnurl=location.href
  354. var tempCnt=strReturnurl.indexOf("&ReturnURL=");
  355. var straction=strReturnurl.substring(0,tempCnt)
  356. objForm.action = straction
  357. objForm.Method.value = ""
  358. // Set OK Button status
  359. if ( objForm.txtGroupName )
  360. {
  361. if ( document.frmTask.txtGroupName.value.length < 1 )
  362. {
  363. DisableOK();
  364. }
  365. else
  366. {
  367. EnableOK();
  368. }
  369. }
  370. //Checks for whether there are any members in the domain
  371. //if its general tab
  372. if(intSelTab == '0')
  373. {
  374. objForm.txtGroupName.focus()
  375. }
  376. else
  377. {
  378. if(objForm.lstDomainMembers.length == 0 )
  379. {
  380. objForm.lstDomainMembers.disabled = true;
  381. objForm.btnAddMember.disabled = true;
  382. objForm.btnRemoveMember.disabled = true;
  383. }
  384. else
  385. {
  386. objForm.lstDomainMembers.options[0].selected = true;
  387. }
  388. if (objForm.lstCurrrentMembers.length ==0)
  389. {
  390. objForm.btnRemoveMember.disabled=true
  391. }
  392. else
  393. {
  394. objForm.lstCurrrentMembers.options[0].selected =true;
  395. objForm.btnRemoveMember.disabled =false
  396. }
  397. disableAddButton(document.frmTask.txtDomainUser,document.frmTask.btnAddDomainMember)
  398. <% If ( G_CREDENTIAL_ERROR ) Then %>
  399. objForm.txtCredentialID.focus();
  400. <% End If %>
  401. }
  402. }
  403. // Validate the page form values
  404. function ValidatePage()
  405. {
  406. var strGroupName
  407. var strErrmsg
  408. if(intSelTab == '0')
  409. {
  410. strGroupName = document.frmTask.txtGroupName.value
  411. strErrmsg = ""
  412. if (Trim(strGroupName) == "" || isAlldots(strGroupName))
  413. {
  414. strErrmsg = "<%=Server.HTMLEncode(L_GROUPNAMENOTVALID_ERRORMESSAGE)%>" + strGroupName + " <%=Server.HTMLEncode(L_INVALIDCHARACTER_ERRORMESSAGE)%>"
  415. DisplayErr(strErrmsg);
  416. //if its general tab
  417. if(intSelTab == '0')
  418. {
  419. document.frmTask.txtGroupName.focus()
  420. document.frmTask.onkeypress = ClearErr
  421. }
  422. return false;
  423. }
  424. // Checks for invalid key entry
  425. if(!isvalidchar("/[\/\*\?\"<>\|+=,;:\[\\]\\\\\]/",strGroupName))
  426. {
  427. strErrmsg = "<%=Server.HTMLEncode(L_GROUPNAMENOTVALID_ERRORMESSAGE)%>" + strGroupName + " <%=Server.HTMLEncode(L_INVALIDCHARACTER_ERRORMESSAGE)%>"
  428. SA_DisplayErr(strErrmsg);
  429. //if its general tab
  430. if(intSelTab == '0')
  431. {
  432. document.frmTask.txtGroupName.focus()
  433. document.frmTask.onkeypress = ClearErr
  434. }
  435. return false;
  436. }
  437. //Checking for length of the description
  438. if(document.frmTask.txaGrpDescription.value.length > 256)
  439. {
  440. SA_DisplayErr("<%=Server.HTMLEncode(L_LONGGRPDESCRIPTION_ERRORMESSAGE) %>");
  441. //if its general tab
  442. if(intSelTab == '0')
  443. {
  444. document.frmTask.txaGrpDescription.focus()
  445. document.frmTask.onkeypress = ClearErr
  446. }
  447. return false;
  448. }
  449. }
  450. return true;
  451. }
  452. // function to set the hidden field with the selected DNS server
  453. // list values
  454. function SetData()
  455. {
  456. var nIdx
  457. var strTemp
  458. strTemp =""
  459. //if its general tab
  460. if(intSelTab == '0')
  461. return true
  462. for(nIdx=0;nIdx < objForm.lstCurrrentMembers.length ; nIdx++)
  463. {
  464. strTemp = strTemp+ String.fromCharCode(1)+ objForm.lstCurrrentMembers.options[nIdx].value
  465. + String.fromCharCode(2)+ objForm.lstCurrrentMembers.options[nIdx].text
  466. }
  467. objForm.hdnGrpMembers.value =strTemp
  468. }
  469. // Adds the group member to the listbox
  470. function addMember()
  471. {
  472. var strText
  473. var objListBox
  474. var strDomainName
  475. var nIdx
  476. var strValue
  477. objListBox = eval("document.frmTask.lstDomainMembers")
  478. if(objListBox.selectedIndex == -1)
  479. {
  480. SA_DisplayErr("<%=Server.HTMLEncode(L_SELECTMEMBER_ERRORMESSAGE)%>");
  481. document.frmTask.onclick = ClearErr
  482. document.frmTask.onkeypress = ClearErr
  483. return false
  484. }
  485. // code added for adding multiple entries into a list box
  486. for(nIdx =0 ; nIdx <objListBox.length ; nIdx++)
  487. {
  488. if(objListBox.options[nIdx].selected)
  489. {
  490. strText = objListBox.options[nIdx].text
  491. strValue = objListBox.options[nIdx].value
  492. addToListBox(objForm.lstCurrrentMembers,document.frmTask.btnRemoveMember,strText,strValue)
  493. objForm.lstCurrrentMembers.disabled= false
  494. }
  495. }
  496. objListBox.selectedIndex = -1
  497. document.frmTask.btnAddMember.disabled = true
  498. }
  499. //Deletes the group member in the listbox
  500. function removeMember()
  501. {
  502. removeListBoxItems(objForm.lstCurrrentMembers,objForm.btnRemoveMember)
  503. }
  504. //Function to enable or disable OK button
  505. function CheckInput(objText)
  506. {
  507. if(objText.value !="")
  508. {
  509. EnableOK();
  510. }
  511. else
  512. {
  513. DisableOK();
  514. }
  515. }
  516. function isAlldots(strInput)
  517. {
  518. var nIdx
  519. for(nIdx=0;nIdx < strInput.length ; nIdx++)
  520. {
  521. if (strInput.charAt(nIdx) != ".")
  522. return false
  523. }
  524. return true
  525. }
  526. //Function to add a domain user
  527. function addDomainMember(objDomainUser)
  528. {
  529. var strText
  530. var strValue
  531. var objListBox
  532. objListBox = eval("document.frmTask.lstDomainMembers")
  533. // Checks For Invalid charecters in username
  534. if(!isvalidchar("/[\/\*\?\"<>\|+=,;:\[\\]\]/",objDomainUser.value))
  535. {
  536. SA_DisplayErr("<% =Server.HTMLEncode(L_DOMUSERINVALIDCHARACTER_ERRORMESSAGE) %>");
  537. document.frmTask.onkeypress = ClearErr
  538. return false;
  539. }
  540. strText =objForm.txtDomainUser.value;
  541. strValue =objForm.txtDomainUser.value;
  542. //Checking for the domain\user format
  543. if( strText.match( /[^(\\| )]{1,}\\[^(\\| )]{1,}/ ) )
  544. {
  545. if(!addToListBox(objForm.lstCurrrentMembers,objForm.btnAddDomainMember,strText,strValue))
  546. {
  547. SA_DisplayErr("<%=Server.HTMLEncode(L_DUPLICATEMEMBER_ERRORMESSAGE)%>");
  548. document.frmTask.onkeypress = ClearErr
  549. return false;
  550. }
  551. objForm.txtDomainUser.value =""
  552. objForm.btnAddDomainMember.disabled = true;
  553. if(objListBox.length != 0 )
  554. {
  555. objForm.btnRemoveMember.disabled = false;
  556. }
  557. }
  558. else
  559. {
  560. SA_DisplayErr("<%=Server.HTMLEncode(L_INVALIDDOMAINUSER_ERRORMESSAGE)%>");
  561. document.frmTask.onkeypress = ClearErr
  562. }
  563. }
  564. </script>
  565. <%
  566. End Function
  567. '---------------------------------------------------------------------
  568. 'Function name: CreateNewGroup
  569. 'Desription: Serves in Creating the NewGroup
  570. 'Input Variables: None
  571. 'Output variables: None
  572. 'Returns: True / Flase on success/Failure
  573. 'Global Variables: F_strGroupName,F_strGrpdescription,F_strUsersList,
  574. ' F_strCurrentGroupMembers,F_strCredentialID, F_strCredentialPSW,
  575. ' G_CREDENTIAL_ERROR,G_objService,L_(*)
  576. '---------------------------------------------------------------------
  577. Function CreateNewGroup
  578. Err.Clear
  579. On Error Resume Next
  580. Dim objComputer
  581. Dim objGroup
  582. Dim arrUserNames
  583. Dim nCnt
  584. Dim nLoopCount
  585. Dim strCompName
  586. Dim strPath
  587. Dim strAdsPath
  588. Dim strDomain
  589. Dim arrTemp
  590. Dim strErrorCode
  591. Dim aParam(1)
  592. Dim strarg
  593. L_CREDENTIALS_ERRORMESSAGE = GetLocString( "usermsg.dll", "C03100CC", strarg)
  594. 'Intializing variables to have the computer name & domain name
  595. strCompName= GetComputerName()
  596. strPath = "Domain="""& strCompName &""",Name="""&F_strGroupName&""""
  597. strDomain = getConnectedDomain(G_objService)
  598. 'Check whether the group already exists
  599. if isValidInstance(G_objService,"win32_group",strPath) then
  600. SetErrMsg L_NONUNIQUEGROUPNAME_ERRORMESSAGE
  601. CreateNewGroup = false
  602. Exit Function
  603. end if
  604. 'If the system is in a domain
  605. if strDomain <> "" then
  606. F_strCurrentGroupMembers = replace(F_strCurrentGroupMembers,chr(1)&strCompName ,chr(1)&strDomain & "\"&strCompName)
  607. end if
  608. 'Replace "\" with "/"
  609. F_strCurrentGroupMembers = replace(F_strCurrentGroupMembers,"\","/")
  610. arrUserNames=split(F_strCurrentGroupMembers,chr(1))
  611. nLoopCount=Ubound(arrUserNames)
  612. 'Looping for each user in the selected List
  613. For nCnt=1 To nLoopCount
  614. arrTemp =split(arrUserNames(nCnt),chr(2))
  615. If instr(arrTemp(1) ,"/") > 0 then
  616. 'If Instr(strUserName,"/") then
  617. If isValidMember(arrTemp(1), F_strCredentialID, F_strCredentialPSW, strErrorCode) = false then
  618. If (strErrorCode = GC_ERR_ACCESS_DENIED ) Then
  619. aParam(0) = replace(arrTemp(1),"/","\")
  620. strarg = aParam
  621. SetErrMsg L_CREDENTIALS_ERRORMESSAGE
  622. G_CREDENTIAL_ERROR = TRUE
  623. Else
  624. Call SA_TraceOut(SA_GetScriptFileName(), "IsValidMember failed, error: " & Hex(Err.Number) & " " & Err.Description)
  625. SetErrMsg L_USERNOTFOUND_ERRORMESSAGE & replace(arrTemp(1),"/","\")
  626. End If
  627. 'Replace "\" with "/"
  628. F_strCurrentGroupMembers = replace(F_strCurrentGroupMembers,"/","\")
  629. CreateNewGroup=FALSE
  630. Exit Function
  631. End if
  632. 'End if
  633. End if
  634. Next
  635. ' End for loop
  636. 'Get the ADSI computer object
  637. Set objComputer = GetObject("WinNT://" & strCompName & ",computer")
  638. 'Create the group & set the description
  639. Set objGroup=objComputer.Create("Group",F_strGroupName)
  640. objGroup.Description=F_strGrpDescription
  641. 'Set the changes
  642. objGroup.setInfo()
  643. 'Error handling
  644. If Err.number <> 0 Then
  645. 'Checking for uniqueness of the GroupName
  646. If Err.Number = N_NONUNIQUEGROUPNAME_ERRNO then
  647. SetErrMsg L_NONUNIQUEGROUPNAME_ERRORMESSAGE
  648. 'Checking for uniqueness of the AccountName
  649. Elseif Err.number = N_ACCOUNTALREADYEXIST_ERRNO then
  650. SetErrMsg L_ACCOUNTALREADYEXIST_ERRORMESSAGE
  651. Else
  652. SetErrMsg L_GROUPNOTCREATED_ERRORMESSAGE
  653. End If
  654. CreateNewGroup=FALSE
  655. Exit Function
  656. End If
  657. 'Looping for each user in the selected List
  658. For nCnt=1 To nLoopCount
  659. arrTemp =split(arrUserNames(nCnt),chr(2))
  660. If ( Len(Trim(F_strCredentialID)) > 0 ) Then
  661. Call AddUserToGroup( F_strGroupName, arrTemp(0), F_strCredentialID, F_strCredentialPSW )
  662. If ( Err.Number <> 0 ) Then
  663. Exit For
  664. End If
  665. Else
  666. strAdsPath="WinNT://" & arrTemp(0)
  667. objGroup.add(strAdsPath)
  668. End If
  669. Next
  670. 'Set to Nothing
  671. Set objComputer =Nothing
  672. set objGroup =Nothing
  673. 'Error handling
  674. If Err.number <> 0 Then
  675. 'checking for user existence
  676. If Err.number = N_GROUPNOTPRESENT_ERRNO Then
  677. SetErrMsg L_GROUPNOTPRESENT_ERRORMESSAGE
  678. Else
  679. SetErrMsg L_MEMBERADDITIONFAILED_ERRORMESSAGE
  680. End If
  681. 'Replace "\" with "/"
  682. F_strCurrentGroupMembers = replace(F_strCurrentGroupMembers,"/","\")
  683. CreateNewGroup=FALSE
  684. Exit Function
  685. End If
  686. CreateNewGroup=TRUE
  687. End Function
  688. %>