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.
454 lines
12 KiB
454 lines
12 KiB
<HTML>
|
|
<HEAD>
|
|
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
|
|
<TITLE>WMI Scripting Sample - Security Descriptor Viewer</TITLE>
|
|
<LINK REL="STYLESHEET" HREF="sdstyle.css">
|
|
<OBJECT id=locator CLASSID="CLSID:BF37162F-9E73-48ed-B009-92E2F732252F"></OBJECT>
|
|
<SCRIPT language=VBScript>
|
|
|
|
dim sd
|
|
dim saclAceArray ()
|
|
dim daclAceArray ()
|
|
|
|
Sub window_onload
|
|
' Test code to fake up an SD - remove this with a real SD when
|
|
' it's all working
|
|
set sacl = CreateObject("AccessControlList")
|
|
set dacl = CreateObject("AccessControlList")
|
|
set sd = CreateObject("SecurityDescriptor")
|
|
sd.SystemAcl = sacl
|
|
sd.DiscretionaryAcl = dacl
|
|
End Sub
|
|
|
|
Sub DisplaySD (sd)
|
|
on error resume next
|
|
sdRevision.innerText = sd.Revision
|
|
sdOwner.innerText = sd.Owner
|
|
sdOwnerDefaulted.innerText = sd.OwnerDefaulted
|
|
sdGroup.innerText = sd.Group
|
|
sdGroupDefaulted.innerText = sd.GroupDefaulted
|
|
sdDaclDefaulted.innerText = sd.DaclDefaulted
|
|
sdSaclDefaulted.innerText = sd.SaclDefaulted
|
|
|
|
DisplayAcl sd.DiscretionaryAcl, true
|
|
DisplayAcl sd.SystemAcl, false
|
|
End Sub
|
|
|
|
Sub DisplayAcl (acl, bIsDacl)
|
|
on error resume next
|
|
|
|
if bIsDacl then
|
|
daclAclRevision.innerText = acl.AclRevision
|
|
daclAceCount.innerText = acl.AceCount
|
|
DisplayAces acl, daclAces, bIsDacl
|
|
else
|
|
saclAclRevision.innerText = acl.AclRevision
|
|
saclAceCount.innerText = acl.AceCount
|
|
DisplayAces acl, saclAces, bIsDacl
|
|
end if
|
|
End Sub
|
|
|
|
Sub DisplayAces (acl, aclAceTable, bIsDacl)
|
|
on error resume next
|
|
ClearAceInfo aclAceTable, bIsDacl
|
|
|
|
for each ace in acl
|
|
DisplayAce ace, aclAceTable, bIsDacl
|
|
next
|
|
End Sub
|
|
|
|
Sub DisplayAce (ace, aclAceTable, bIsDacl)
|
|
on error resume next
|
|
set newRow = aclAceTable.insertRow (-1)
|
|
|
|
newRow.insertCell (-1).innerText = Hex(ace.AccessMask)
|
|
newRow.insertCell (-1).innerText = ace.AceType
|
|
newRow.insertCell (-1).innerText = ace.AceFlags
|
|
newRow.insertCell (-1).innerText = ace.Flags
|
|
newRow.insertCell (-1).innerText = ace.ObjectType
|
|
newRow.insertCell (-1).innerText = ace.InheritedObjectType
|
|
newRow.insertCell (-1).innerText = ace.Trustee
|
|
|
|
' Add a delete button
|
|
set newCell = newRow.insertCell (-1)
|
|
|
|
if bIsDacl then
|
|
newCell.innerHTML = _
|
|
"<SPAN CLASS=HotText2 onmouseover=""this.style.cursor='hand'"" onmouseout=""this.style.cursor='auto'"" onclick='DeleteAce(this.parentElement.parentElement, true)'>Delete</SPAN>"
|
|
else
|
|
newCell.innerHTML = _
|
|
"<SPAN CLASS=HotText2 onmouseover=""this.style.cursor='hand'"" onmouseout=""this.style.cursor='auto'"" onclick='DeleteAce(this.parentElement.parentElement, false)'>Delete</SPAN>"
|
|
end if
|
|
|
|
' Add a modify button
|
|
set newCell = newRow.insertCell (-1)
|
|
|
|
if bIsDacl then
|
|
newCell.innerHTML = _
|
|
"<SPAN CLASS=HotText2 onmouseover=""this.style.cursor='hand'"" onmouseout=""this.style.cursor='auto'"" onclick='ModifyAce(this.parentElement.parentElement, true)'>Modify</SPAN>"
|
|
else
|
|
newCell.innerHTML = _
|
|
"<SPAN CLASS=HotText2 onmouseover=""this.style.cursor='hand'"" onmouseout=""this.style.cursor='auto'"" onclick='ModifyAce(this.parentElement.parentElement, false)'>Modify</SPAN>"
|
|
end if
|
|
|
|
' Remember our ACE in case we need to delete or modify it
|
|
|
|
if bIsDacl then
|
|
if IsNull(daclAceArray) then
|
|
daclAceArray = Array (0)
|
|
set daclAceArray(0) = ace
|
|
else
|
|
bound = aclAceTable.rows.length - 1
|
|
Redim Preserve daclAceArray (bound)
|
|
set daclAceArray (bound) = ace
|
|
end if
|
|
else
|
|
if IsNull(saclAceArray) then
|
|
saclAceArray = Array (0)
|
|
set saclAceArray(0) = ace
|
|
else
|
|
bound = aclAceTable.rows.length - 1
|
|
Redim Preserve saclAceArray (bound)
|
|
set saclAceArray (bound) = ace
|
|
end if
|
|
end if
|
|
End Sub
|
|
|
|
Sub RefreshAce (row, ace)
|
|
row.cells(0).innerText = Hex(ace.AccessMask)
|
|
row.cells(1).innerText = ace.AceType
|
|
row.cells(2).innerText = ace.AceFlags
|
|
row.cells(3).innerText = ace.Flags
|
|
row.cells(4).innerText = ace.ObjectType
|
|
row.cells(5).innerText = ace.InheritedObjectType
|
|
row.cells(6).innerText = ace.Trustee
|
|
End Sub
|
|
|
|
Sub DeleteAce (row, bIsDacl)
|
|
if bIsDacl then
|
|
set ace = daclAceArray (row.rowIndex - 1)
|
|
else
|
|
set ace = saclAceArray (row.rowIndex - 1)
|
|
end if
|
|
|
|
row.removeNode true
|
|
|
|
if err <> 0 then
|
|
alert "Error!"
|
|
else
|
|
if bIsDacl then
|
|
sd.DiscretionaryAcl.RemoveAce (ace)
|
|
else
|
|
sd.SystemAcl.RemoveAce (ace)
|
|
end if
|
|
end if
|
|
End Sub
|
|
|
|
Sub ClearSDInfo
|
|
on error resume next
|
|
sdRevision.innerText = ""
|
|
sdOwner.innerText = ""
|
|
sdOwnerDefaulted.innerText = ""
|
|
sdGroup.innerText = ""
|
|
sdGroupDefaulted.innerText = ""
|
|
sdDaclDefaulted.innerText = ""
|
|
sdSaclDefaulted.innerText = ""
|
|
ClearAclInfo true
|
|
ClearAclInfo false
|
|
End Sub
|
|
|
|
Sub ClearAclInfo (bIsDacl)
|
|
on error resume next
|
|
|
|
if bIsDacl then
|
|
daclAclRevision.innerText = ""
|
|
daclAceCount.innerText = ""
|
|
ClearAceInfo daclAces, bIsDacl
|
|
else
|
|
saclAclRevision.innerText = ""
|
|
saclAceCount.innerText = ""
|
|
ClearAceInfo saclAces, bIsDacl
|
|
end if
|
|
End Sub
|
|
|
|
Sub ClearAceInfo (aceTable, bIsDacl)
|
|
on error resume next
|
|
|
|
numRows = aceTable.rows.length
|
|
|
|
if numRows > 0 then
|
|
for i = 0 to (numRows-1)
|
|
aceTable.deleteRow i
|
|
next
|
|
end if
|
|
|
|
if bIsDacl then
|
|
if Not(IsNull(daclAceArray)) then set daclAceArray = null
|
|
else
|
|
if Not(IsNull(saclAceArray)) then set saclAceArray = null
|
|
end if
|
|
|
|
End Sub
|
|
|
|
'***************************************************************
|
|
' Handles the onclick event for the Security Descriptor hot text
|
|
'***************************************************************
|
|
Sub getSD_onclick
|
|
on error resume next
|
|
|
|
' Show that we're busy
|
|
getSD.style.cursor = "wait"
|
|
ClearSDInfo
|
|
window.defaultStatus = "Retrieving value..."
|
|
|
|
' Attempt to open the required object
|
|
' set obj = locator.Open (objectPath.value, user.value, password.value)
|
|
|
|
' Temporary hack
|
|
err.clear
|
|
set ldap = locator.Open (objectPath.value, user.value, password.value)
|
|
if err then
|
|
window.alert ("Error opening ldap: 0x" & Hex(err.Number) & " : " & err.Description)
|
|
end if
|
|
|
|
Set c = CreateObject("WbemScripting.SWbemNamedValueSet")
|
|
c.Add "INCLUDE_OWNER", true
|
|
c.Add "INCLUDE_GROUP", true
|
|
c.Add "INCLUDE_DACL", true
|
|
c.Add "INCLUDE_SACL", true
|
|
set obj = ldap.Get (".CN=Users", &H40000, c)
|
|
|
|
if err <> 0 then
|
|
window.alert ("Error retrieving object: 0x" & Hex(err.Number) & " : " & err.Description)
|
|
else
|
|
' Try and get the specified Security Descriptor property
|
|
set sd = obj.GetSecurityDescriptor_
|
|
|
|
if err <> 0 then
|
|
window.alert ("Could not get Security Descriptor: 0x" & Hex(err.Number) & " : " & err.Description)
|
|
else
|
|
DisplaySD sd
|
|
end if
|
|
end if
|
|
|
|
getSD.style.cursor = "auto"
|
|
End sub
|
|
|
|
Sub objectPathDiv_onmouseover
|
|
window.status = "Path to the object whose Security Descriptor is to be displayed"
|
|
End Sub
|
|
|
|
Sub objectPathDiv_onmouseout
|
|
window.status = ""
|
|
End Sub
|
|
|
|
Sub nameDiv_onmouseover
|
|
window.status = "Name of the Security Descriptor property to retrieve, or the default (__SD) if not specified"
|
|
End Sub
|
|
|
|
Sub nameDiv_onmouseout
|
|
window.status = ""
|
|
End Sub
|
|
|
|
Sub userPasswordDiv_onmouseover
|
|
window.status = "Explicit user credentials (if required)"
|
|
End Sub
|
|
|
|
Sub userPasswordDiv_onmouseout
|
|
window.status = ""
|
|
End Sub
|
|
|
|
Sub getDiv_onmouseover
|
|
window.status = "Retrieve and display the specified security descriptor"
|
|
getSD.style.color = "Green"
|
|
getSD.style.fontWeight = "bolder"
|
|
getSD.style.cursor = "hand"
|
|
End Sub
|
|
|
|
Sub getDiv_onmouseout
|
|
window.status = ""
|
|
getSD.style.color = "SaddleBrown"
|
|
getSD.style.fontWeight = "lighter"
|
|
getSD.style.cursor = "auto"
|
|
End Sub
|
|
|
|
Sub AddAce (bIsDacl)
|
|
on error resume next
|
|
set ace = window.showModalDialog ("sdaddace.htm",, _
|
|
"help:no;resizable:yes;status:no;dialogWidth:18cm;dialogHeight:15cm")
|
|
|
|
if IsObject(ace) then
|
|
|
|
if bIsDacl then
|
|
sd.DiscretionaryAcl.AddAce ace
|
|
else
|
|
sd.SystemAcl.AddAce ace
|
|
end if
|
|
|
|
if err <> 0 then
|
|
alert Err.Description & ": 0x" & Hex(Err.number)
|
|
else
|
|
if bIsDacl then
|
|
DisplayAce ace, daclAces, true
|
|
else
|
|
DisplayAce ace, saclAces, false
|
|
end if
|
|
end if
|
|
end if
|
|
End Sub
|
|
|
|
Sub ModifyAce (row, bIsDacl)
|
|
|
|
if bIsDacl then
|
|
set ace = daclAceArray (row.rowIndex - 1)
|
|
else
|
|
set ace = saclAceArray (row.rowIndex - 1)
|
|
end if
|
|
|
|
if window.showModalDialog ("sdaddace.htm", ace, _
|
|
"help:no;resizable:yes;status:no;dialogWidth:18cm;dialogHeight:15cm") then
|
|
RefreshAce row, ace
|
|
end if
|
|
End Sub
|
|
|
|
Sub saclAddAce_onmouseover
|
|
saclAddAce.style.color = "Green"
|
|
saclAddAce.style.fontWeight = "bolder"
|
|
saclAddAce.style.cursor = "hand"
|
|
End Sub
|
|
|
|
Sub saclAddAce_onmouseout
|
|
saclAddAce.style.color = "SaddleBrown"
|
|
saclAddAce.style.fontWeight = "lighter"
|
|
saclAddAce.style.cursor = "auto"
|
|
End Sub
|
|
|
|
Sub daclAddAce_onmouseover
|
|
daclAddAce.style.color = "Green"
|
|
daclAddAce.style.fontWeight = "bolder"
|
|
daclAddAce.style.cursor = "hand"
|
|
End Sub
|
|
|
|
Sub daclAddAce_onmouseout
|
|
daclAddAce.style.color = "SaddleBrown"
|
|
daclAddAce.style.fontWeight = "lighter"
|
|
daclAddAce.style.cursor = "auto"
|
|
End Sub
|
|
</SCRIPT>
|
|
</HEAD>
|
|
<BODY>
|
|
<H1>WMI Scripting Sample - Security Descriptor Viewer</H1>
|
|
<P>
|
|
<HR>
|
|
|
|
<P></P>
|
|
<SPAN id=objectPathDiv>
|
|
<P class=ObjectPath>Object Path: <INPUT id=objectPath style="WIDTH: 548px; HEIGHT: 22px" size=78
|
|
name=text1 value=umi://nw01t1/ldap> </P>
|
|
</SPAN>
|
|
<SPAN id=userPasswordDiv>
|
|
<P class=ObjectPath>User: <INPUT id=user value=nw01t1domnb\administrator>
|
|
Password: <INPUT type=password id=password value=nw01t1domnb>
|
|
</SPAN>
|
|
<SPAN id=nameDiv></P></SPAN>
|
|
<P>
|
|
<SPAN id=getDiv><P class=HotText id=getSD align=center>Get the Security Descriptor</P></SPAN>
|
|
<P></P>
|
|
<P>
|
|
<HR>
|
|
|
|
<P></P>
|
|
<H2>Security Descriptor information</H2>
|
|
<P>
|
|
<TABLE CLASS=data cellSpacing=1 cellPadding=1 width="75%" >
|
|
<COLGROUP CLASS=data>
|
|
<COLGROUP CLASS=valueCol>
|
|
<TR>
|
|
<TD>Revision</TD>
|
|
<TD id=sdRevision></TD></TR>
|
|
<TR>
|
|
<TD>Control</TD>
|
|
<TD id=sdControl></TD></TR>
|
|
<TR>
|
|
<TD>Owner</TD>
|
|
<TD id=sdOwner></TD></TR>
|
|
<TR>
|
|
<TD>OwnerDefaulted</TD>
|
|
<TD id=sdOwnerDefaulted></TD></TR>
|
|
<TR>
|
|
<TD>Group</TD>
|
|
<TD id=sdGroup></TD></TR>
|
|
<TR>
|
|
<TD>GroupDefaulted</TD>
|
|
<TD id=sdGroupDefaulted></TD></TR>
|
|
<TR>
|
|
<TD>DaclDefaulted</TD>
|
|
<TD id=sdDaclDefaulted></TD></TR>
|
|
<TR>
|
|
<TD>SaclDefaulted</TD>
|
|
<TD id=sdSaclDefaulted></TD></TR></TABLE></P>
|
|
<H2>
|
|
<HR>
|
|
</H2>
|
|
<H2>System ACL information</H2>
|
|
<P>
|
|
<TABLE CLASS=data cellSpacing=1 cellPadding=1 width="75%">
|
|
<COLGROUP CLASS=data>
|
|
<COLGROUP CLASS=valueCol>
|
|
<TR>
|
|
<TD>AclRevision</TD>
|
|
<TD id=saclAclRevision></TD></TR>
|
|
<TR>
|
|
<TD>AceCount</TD>
|
|
<TD id=saclAceCount></TD></TR></TABLE></P>
|
|
|
|
<H3>ACEs</H3>
|
|
<TABLE CLASS=data cellSpacing=1 cellPadding=1 width="85%" border=1 style="WIDTH: 85%">
|
|
<THEAD>
|
|
<TR>
|
|
<TH>AccessMask</TH>
|
|
<TH>AceType</TH>
|
|
<TH>AceFlags</TH>
|
|
<TH>Flags</TH>
|
|
<TH>ObjectType</TH>
|
|
<TH>InheritedObjectType</TH>
|
|
<TH>Trustee</TH>
|
|
<TH><SPAN CLASS=HotText2 onmouseover="me.style.cursor='hand'"
|
|
onmouseout="me.style.cursor='auto'" onclick="AddAce(false)">Add</SPAN></TH></TR>
|
|
</THEAD>
|
|
<TBODY id=saclAces></TBODY>
|
|
</TABLE>
|
|
<H2>
|
|
<HR>
|
|
</H2>
|
|
<H2>Discretionary ACL Information</H2>
|
|
<P>
|
|
<TABLE CLASS=data cellSpacing=1 cellPadding=1 width="75%">
|
|
<COLGROUP CLASS=data></COLGROUP>
|
|
<COLGROUP CLASS=valueCol></COLGROUP>
|
|
|
|
<TR>
|
|
<TD>AclRevision</TD>
|
|
<TD id=daclAclRevision></TD></TR>
|
|
<TR>
|
|
<TD>AceCount</TD>
|
|
<TD id=daclAceCount></TD></TR></TABLE></P>
|
|
<H3>ACEs</H3>
|
|
<TABLE CLASS=data cellSpacing=1 cellPadding=1 width="85%" border=1 style="WIDTH: 85%">
|
|
<THEAD>
|
|
<TR>
|
|
<TH>AccessMask</TH>
|
|
<TH>AceType</TH>
|
|
<TH>AceFlags</TH>
|
|
<TH>Flags</TH>
|
|
<TH>ObjectType</TH>
|
|
<TH>InheritedObjectType</TH>
|
|
<TH>Trustee</TH>
|
|
<TH><SPAN CLASS=HotText2 onmouseover="me.style.cursor='hand'"
|
|
onmouseout="me.style.cursor='auto'" onclick="AddAce(true)">Add</SPAN></TH></TR>
|
|
</THEAD>
|
|
<TBODY id=daclAces></TBODY>
|
|
</TABLE>
|
|
|
|
</BODY>
|
|
</HTML>
|