<% '------------------------------------------------------------------------- ' sharecifs_new.asp: Create a CIFS share. ' ' Copyright (c) Microsoft Corporation. All rights reserved. ' ' Date Description ' 17 Nov 2001 Creation Date. ' 9 March 2001 Modified Date. '------------------------------------------------------------------------- %> <% '------------------------------------------------------------------------- 'Form Variables '------------------------------------------------------------------------- Dim F_strUserlimitcheck_y 'Allow users radio status value Dim F_strUserlimitcheck_n 'Allow users radio status value Dim F_nUserLimit 'Allow User Limit value Dim F_strUservaluedisable 'Allow user textbox status value Dim F_strCachinglimitcheck 'Folder caching checkbox status value Dim F_strLocalUsers 'All local users and groups Dim F_nCacheOption 'value of the folder cache option Dim F_UserAccessMaskMaster '* seperated string having access control list of user Dim F_flagDisable 'Form controls status value used for Hidden shares Dim F_strPermittedMembers 'Currently selected users and groups Dim F_strAllowUsersData ', seperated string of allowuser flag and value Dim F_strComment 'cifs comment F_strUserlimitcheck_y = "CHECKED" F_strUserlimitcheck_n = "" F_nUserLimit = 0 F_strUservaluedisable = "DISABLED" F_strCachinglimitcheck = "CHECKED" F_nCacheOption = "0" F_UserAccessMaskMaster ="" F_strPermittedMembers ="" F_strAllowUsersData ="" '------------------------------------------------------------------------- 'Global Variables '------------------------------------------------------------------------- Dim G_objService 'object to WMI service Dim G_strLocalmachinename 'Local machine name Dim G_strTemp 'Allow user temp array set G_objService = getWMIConnection(CONST_WMI_WIN32_NAMESPACE) G_strLocalmachinename = GetComputerName() %> <% '------------------------------------------------------------------------- ' Function name: ServeCIFSPage ' Description: Serves in displaying the page Header,Middle,Bottom Parts. ' Input Variables: None. ' Output Variables: None ' Return Values: None. '------------------------------------------------------------------------- Function ServeCIFSPage %>
<%=L_COMMENT_TEXT%>    " size=53>
<%=L_USERLIMIT_TEXT%>    OnClick ="javascript:allowUserValueEdit(this)" > <%=L_MAXIMUMALLOWED_TEXT%>
     OnClick ="javascript:allowUserValueEdit(this)"> <%=L_ALLOW_TEXT%> tabindex="2" OnKeyUP="javaScript:checkUserLimit(this)" OnKeypress="javaScript:checkkeyforNumbers(this)">
OnClick="EnableorDisableCacheProp(this)" > <%=L_ALLOWCACHING_TEXT %>

<%=L_SETTING_TEXT%>   

<%=L_PERMISSIONS_TEXT%> <%=L_ALLOWPROMPT_TEXT%> <%=L_DENYPROMPT_TEXT%>


<% Call SA_ServeOnClickButtonEx(L_CIFS_ADD_TEXT, "", "addDomainMember(document.frmTask.txtDomainUser)", 60, 0, F_flagDisable, "btnAddDomainMember") %>

<% Call SA_ServeOnClickButtonEx(L_CIFS_ADD_TEXT, "", "addMember()", 60, 0, F_flagDisable, "btnAddMember") %>

<% Call SA_ServeOnClickButtonEx(L_CIFS_REMOVE_TEXT, "", "removeMember()", 60, 0, F_flagDisable, "btnRemoveMember") %>


<%=L_CIFSADDUSERORGROUP_TEXT %>

<%=L_ADDUSERHELP_TEXT%>
<% Call ServeCIFSHiddenValues End Function '------------------------------------------------------------------------- ' Function name: CIFSOnPostBackPage ' Description: Serves in getting the values from previous form ' Input Variables: None. ' Output Variables: None ' Return Values: None ' Global Variables: Out: F_strPermittedMembers - Currently selected users ' and groups ' Out: F_UserAccessMaskMaster - * seperated string ' having access control list of user ' Out: F_nCacheOption -value of the folder cache option ' Out: F_strAllowUsersData - , seperated string of ' allowuser flag and value ' Out: F_flagDisable -Form controls status value ' Out: F_strComment - Share description ' Out: G_strTemp -Allow user temp array ' in: G_objService - object to WMI service '------------------------------------------------------------------------- Function CIFSOnPostBackPage Err.Clear On Error Resume Next F_strComment = Request.Form ("hdnComment") F_strPermittedMembers = Request.Form ("hdnCurrentUsers") F_UserAccessMaskMaster = Request.Form ("hdnUserAccessMaskMaster") F_nCacheOption = Request.Form ("hdnCacheValue") F_strAllowUsersData = Request.Form ("hdnAllowUsers") F_strLocalUsers = getLocalUsersList(G_objService) F_strLocalUsers = F_strLocalUsers & Getbuiltingroups(G_objService) F_strLocalUsers = F_strLocalUsers & getGroups(G_objService,G_strLocalmachinename) 'added for coment updation F_strComment = F_strNewDescription F_strShareName = F_strNewSharename F_strSharePath = F_strNewSharePath G_strTemp = split(F_strAllowUsersData,",") if G_strTemp(0) = "n" then checkradio G_strTemp(1),"n" else checkradio "","y" end if End Function '------------------------------------------------------------------------- ' Function name: CIFSOnInitPage ' Description: Serves in getting the values from system ' Input Variables: None. ' Output Variables: None ' Return Values: None ' Global Variables: Out: F_strPermittedMembers - Currently selected users ' and groups ' Out: F_UserAccessMaskMaster - * seperated string ' having access control list of user ' Out: F_nCacheOption -value of the folder cache option ' Out: F_strAllowUsersData - , seperated string of ' allowuser flag and value ' Out: F_flagDisable -Form controls status value ' Out: F_strComment - Share description ' in: G_objService - object to WMI service '------------------------------------------------------------------------- Function CIFSOnInitPage Err.Clear On Error Resume Next F_strLocalUsers = getLocalUsersList(G_objService) F_strLocalUsers = F_strLocalUsers & Getbuiltingroups(G_objService) F_strLocalUsers = F_strLocalUsers & getGroups(G_objService,G_strLocalmachinename) F_strShareName = F_strNewSharename F_strSharePath = F_strNewSharePath Dim sEveryone sEveryone = SA_GetAccount_Everyone() F_strPermittedMembers = chr(1)& sEveryone & chr(2)& sEveryone F_UserAccessMaskMaster ="*" & "" &"," & sEveryone & "," & 2032127 &","& 0 & "," & "a" If instr(F_strSharesChecked,"W") > 0 Then F_nCacheOption = getShareCacheProp(F_strShareName) getCIFSshareProp() End if End Function '------------------------------------------------------------------------- ' Function name: SetCIFSshareProp ' Description: To set the sharedescritpion,maximum allowed users , ' users and their allowed permissions of the given share ' Input Variables: None. ' Output Variables: None ' Return Values: True on sucess, False on error (and error msg ' will be set by SA_SetErrMsg) ' Global Variables: in: F_strShareName -CIFS share name ' in: F_UserAccessMaskMaster - * seperated string having access control list of user ' in: F_nCacheOption -value of the folder cache option ' in: F_strAllowUsersData - , seperated string of allowuser flag and value ' in: F_flagDisable -Form controls status value used for Hidden shares ' in: F_strComment - Share description ' in: G_objService - object to WMI service ' in: L_SHARENAMENOTFOUND_ERRORMESSAGE ' in: L_FAILEDTOSETSHAREINFO_ERRORMESSAGE ' Updates system with CIFS properties as given by F_UserAccessMaskMaster. If an error ' occurs, sets error message with SA_SetErrMsg and exits with False. '------------------------------------------------------------------------- function SetCIFSshareProp() Err.Clear On Error resume next Dim objShareInstance Dim objclass Dim objSecDescriptor Dim nRetVal Dim strDomain Dim strUser Dim strAccess Dim strAce Dim i Dim objACE Dim objTrustee Dim arrSubAccessMask DIm arrShareItem Dim arrUserSID Dim objDACL Dim strWMIPath Dim sEveryone sEveryone = SA_GetAccount_Everyone() 'Setting the User EVERYONE deny FullControl Accessmask If (F_UserAccessMaskMaster = "") then F_UserAccessMaskMaster = "*" & "" & "," & sEveryone & "," & "0" & "," & "0" End If arrSubAccessMask = split(F_UserAccessMaskMaster,"*") Set objShareInstance = G_objService.Get("Win32_Share.Name=" & chr(34) & F_strShareName & chr(34)) '------------- Localization String ------------- Dim arrVarReplacementString(0) arrVarReplacementString(0) = F_strShareName DIM L_SHARENAMENOTFOUND_ERRORMESSAGE L_SHARENAMENOTFOUND_ERRORMESSAGE = SA_GetLocString("foldermsg.dll", "C03A005B", arrVarReplacementString) '------------ Dim strNTAuthorityDomainName Dim strBuiltinDomainName ' Get localized domain names strNTAuthorityDomainName = getNTAuthorityDomainName(G_objService) strBuiltinDomainName = getBuiltinDomainName(G_objService) If Err.number <> 0 Then SA_SetErrMsg(L_SHARENAMENOTFOUND_ERRORMESSAGE ) SetCIFSshareProp =FALSE Exit Function End If 'checking whether the added domain user existance for i=0 to Ubound(arrSubAccessMask)-1 arrShareItem = split(arrSubAccessMask(i+1),",") strDomain = arrShareItem(0) strUser = arrShareItem(1) '------------- Localization String ------------- Dim arrVarReplacementStrings(0) arrVarReplacementStrings(0) = strDomain & "\" & strUser DIM L_USERNOTFOUND_ERRORMESSAGE L_USERNOTFOUND_ERRORMESSAGE = SA_GetLocString("foldermsg.dll", "C03A0062", arrVarReplacementStrings) '------------ 'Do not check if user is local or SID string If Left(strUser,1) <> "?" Then If not( UCASE(strDomain) = UCASE(G_strLocalmachinename) or UCASE(strDomain) = UCASE(strNTAuthorityDomainName) or UCASE(strDomain)= UCASE(strBuiltinDomainName) or strDomain = "") then strWMIPath = "Domain=" & chr(34) & strDomain & chr(34) & "," & "Name=" & chr(34) & strUser & chr(34) if (not (isValidInstance(G_objService,"Win32_Account",strWMIPath))) then SA_SetErrMsg L_USERNOTFOUND_ERRORMESSAGE & " (" & Hex(Err.Number) & ")" SetCIFSshareProp =FALSE Exit function End If End If End If Next Set objclass = G_objService.Get("Win32_SecurityDescriptor") Set objSecDescriptor = objclass.SpawnInstance_() 'Hardcoding the Control Flag value objSecDescriptor.Properties_.Item("ControlFlags") = 32772 objSecDescriptor.Properties_.Item("DACL") = Array() Set objDACL = objSecDescriptor.Properties_.Item("DACL") for i=0 to Ubound(arrSubAccessMask)-1 arrShareItem = split(arrSubAccessMask(i+1),",") strDomain = arrShareItem(0) strUser = arrShareItem(1) strAccess = arrShareItem(2) strAce = arrShareItem(3) 'If Username has "?" at start of the string then get SID based on SID string 'Else get SID for username ,Domain. If Left(strUser,1) <> "?" Then arrUserSID = getsidvalue(strUser,strDomain) Else strUser = Right(strUser, (Len(strUser) - 1)) arrUserSID = getBinarySIDforstirngSID(strUser) End if Set objTrustee = SetTrustee(strDomain,strUser,arrUserSID) Set objACE = SetACE(strAccess, 3, strAce, objTrustee) objDACL.Value(i) = objACE Next if (G_strTemp(0) = "n") then If (objShareInstance.Type <> 0) then nRetVal = objShareInstance.SetShareInfo(F_nUserLimit,F_strComment) else nRetVal = objShareInstance.SetShareInfo(F_nUserLimit, F_strComment, objSecDescriptor) End If else If (objShareInstance.Type <> 0) then nRetVal = objShareInstance.SetShareInfo(4294967295,F_strComment) else nRetVal = objShareInstance.SetShareInfo(4294967295, F_strComment, objSecDescriptor) End If End If If nRetVal = 0 and Err.number = 0 then SetCIFSshareProp =TRUE else SA_SetErrMsg L_FAILEDTOSETSHAREINFO_ERRORMESSAGE & "(" & Err.Number & ")" SetCIFSshareProp =FALSE End If 'setting cache options if(setShareCacheProp(F_strShareName,F_nCacheOption)) then SetCIFSshareProp =TRUE else SetCIFSshareProp =FALSE end If SetCIFSshareProp = True End FUnction '------------------------------------------------------------------------- ' Function name: getCIFSshareProp ' Description: gets the CIFS properties from system ' Input Variables: None. ' Output Variables: None ' Return Values: True on sucess, False on error (and error msg ' will be set by SA_SetErrMsg) ' Global Variables: In: F_strShareName -CIFS share name ' Out: F_flagDisable -Form controls status value used for Hidden shares ' In: G_objService - object of WMI service ' In: L_SHARENOTFOUND_ERRORMESSAGE ' Gets the CIFS Allow maximum values and if share type is hidden the F_flagDisable ' is assigned "DISABLE".If unable to find the share name then calls ' servefailure page '------------------------------------------------------------------------- Function getCIFSshareProp() Err.Clear On Error resume next Dim objShare Dim objSharePath objSharePath = "Win32_Share.Name=" & "'" & F_strShareName & "'" set objShare = G_objService.Get(objSharePath) If Err.Number <> 0 then Call SA_ServeFailurepageEx(L_SHARENOTFOUND_ERRORMESSAGE,mstrReturnURL) Exit Function End If If objShare.AllowMaximum = false then checkradio objShare.MaximumAllowed,"n" else checkradio "","y" End if getCIFSshareProp = True End FUnction '------------------------------------------------------------------ 'Function name: ServeCIFSHiddenValues() 'Description: Serve Hidden Values 'Input Variables: None 'Output Variables: None 'Global Variables: F_(*) '------------------------------------------------------------------ Function ServeCIFSHiddenValues %> "> <% End Function %>