本文介绍了错误1307:使用ASP.NET中的System.Management对象向NTFS添加文件权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 项目: ---------------------------- 我正在使用ASP.NET和C#创建HTTPS文件传输应用程序。我是使用ActiveDirectory和windows安全性来管理 权限的。为什么重新发明轮子吧?到目前为止,所有内容都是与Active Directory配合良好的。我遇到的问题是向目录添加文件权限 。我目前正在使用 一些代码由Willy Denoyette [MVP]提供 问题: --- ------------------------- 当我尝试使用以下命令将用户权限添加到特定文件夹时相同的 代码在示例控制台应用程序中它可以正常工作。当我从ASP.NET执行 代码时,每次都会得到1307的返回代码。 这意味着 - 1307可能不会分配此安全ID作为这个对象的拥有者 。 ( http://www.hiteksoftware.com/mize/ Kn ... icles / 049.htm)。 谁能告诉我为什么会这样?威利? 环境: -------------------------- - 我正在使用Framework 1.1和Windows XP进行开发。在Windows 2003 Server上来自AD的用户是。 我已经给ASPNET对象完全访问文件夹C:\ test。我有 也给ASPNET对象完全访问Root / CIMV2 CompMgmt.msc / Services and Apps / WMI Control 代码: ---------------------------- DsSettings对象只是一个简单的类,其中包含Login 和LDAP的路径信息。 public bool GrantPermission(字符串用户名,字符串域,DsSettings 设置) { 试试 { byte [] bSid =(byte [] )DsWrapper.GetUser(用户名, 设置).DsEntry.Properties [" objectSID"]。值; ManagementObject LogicalFileSecuritySetting = new ManagementObject(新的ManagementPath( @" ROOT \\ _CIMV2:Win32_LogicalFileSecuritySetting.Path =''c:\\test''")); ManagementBaseObject outParams; outParams = LogicalFileSecuritySetting.InvokeMethod(" GetSecuri tyDescriptor", null,null); ManagementBaseObject Descriptor = ((ManagementBaseObject)(outParams.Properties [" Descriptor"]。Value)); ManagementBaseObject [] DACLObject =((ManagementBaseObject []) ( Descriptor.Properties [" DACL"]。Value)); ManagementObject newTrusteeUser =(new ManagementClass( ) @" ROOT\CIMV2:Win32_Trustee" ).CreateInstance(); newTrusteeUser [" Domain"] = domain; newTrusteeUser [" Name"] = username; newTrusteeUser [" SID"] = bSid; ManagementObject newACEUser =(new ManagementClass( @" ROOT \CIMV2:Win32_Ace")) .CreateInstance(); newACEUser [" Trustee"] = newTrusteeUser; newACEUser [" AceFlags"] = 3; newACEUser [" AceType"] = 0; newACEUser [" AccessMask"] = 2032127; //完全访问掩码 ManagementBaseObject [] DACLObjectNew = new ManagementBaseObject [] {newACEUser}; Descriptor.Properties [" DACL"]。Value = DACLObjectNew; ManagementBaseObject inParams = null; inParams = LogicalFileSecuritySetting.GetMethodParameters(" Se tSecurityDescriptor"); inParams [" Descriptor"] = Descriptor; outParams = LogicalFileSecuritySettin g.InvokeMethod(SetSecuri tyDescriptor, inParams,null); //此行是我在ASP中获得1307结果的地方.NET uint result =(uint)(outParams.Properties [" ReturnValue"]。Value); LogicalFileSecuritySetting.Dispose(); 返回true; } catch(Exception exp) { throw exp ; } } 日志: ------------- --------------- C:\ WINDOWS \system32 \ WBEM\Logs\Framework.log ---------------------------- 无法找到Shell Process,模拟失败。 05/06/2004 09:39:06.093 thread:1916 [d:\ xpsp1 \admin\wmi\wbem\providers\win32provider\co mmon\implogonuser。 cpp.179] 在进程中找不到Shell名称Explorer.exe在进程中找到 list。 05/06/2004 09:39:06.203主题:2540 [d:\ xpsp1 \admin \wmi \ wbem \ providers \ win32provider\co mmon\implogonuser.cpp.163] 无法找到Shell Process,模拟失败。 05/06/2004 09:39:06.203主题:2540 [d:\ xpsp1 \admin\wmi \wbem \ providers \ win32provider\co mmon\implogonuser。 cpp.179] 在进程中找不到Shell名称Explorer.exe在进程中找到 list。 05/06/2004 09:39:07.968主题:1916 [d:\ xpsp1 \admin \wmi \ wbem \ providers \ win32provider\co mmon\implogonuser.cpp.163] 无法找到Shell Process,模拟失败。 05/06/2004 09:39:07.984主题:1916 [d:\ xpsp1 \admin\wmi \wbem \ providers \ win32provider\co mmon\implogonuser。 cpp.179] 在进程中找不到Shell名称Explorer.exe在进程中找到 list。 05/06/2004 09:39:07.984主题:1916 [d:\ xpsp1 \admin \wmi \wbem \ providers \ win32provider\co mmon \ implogonuser.cpp.163] 无法找到Shell Process,模拟失败。 05/06/2004 09:39:08.000主题:1916 [d:\ xpsp1 \admin \wmi \wbem \ providers \ win32provider\co mmon\implogonuser。 cpp.179] 在进程中找不到Shell名称Explorer.exe在进程中找到 list。 05/06/2004 09:39:08.093主题:1916 [d:\ xpsp1 \admin \wmi \ wbem \ providers \ win32provider\co mmon \ implogonuser.cpp.163] 无法找到Shell Process,模拟失败。 05/06/2004 09:39:08.093 thread:1916 [d:\ xpsp1 \admin\wmi \wbem \ providers \ win32provider\co mmon\implogonuser。 cpp.179] 在进程中找不到Shell名称Explorer.exe在进程中找到 list。 05/06/2004 09:39:08.203主题:2540 [d:\ xpsp1 \admin \wmi \ wbem \ providers \ win32provider\co mmon \ implogonuser.cpp.163] 无法找到Shell Process,模拟失败。 05/06/2004 09:39:08.203主题:2540 [d:\ xpsp1 \admin\wmi \wbem \ providers \ win32provider\co mmon\implogonuser。 cpp.179] 在进程中找不到Shell名称Explorer.exe在进程中找到 list。 05/06/2004 09:39:08.218主题:2540 [d:\ xpsp1 \admin \wmi \ wbem \ providers \ win32provider\co mmon \ implogonuser.cpp.163] 无法找到Shell Process,模拟失败。 05/06/2004 09:39:08.218主题:2540 [d:\ xpsp1 \admin \wmi \ wbem \ providers \ win32provider\co mmon\implogonuser。 cpp.179] 在进程中找不到Shell名称Explorer.exe在进程中找到 list。 05/06/2004 09:39:08.312主题:2540 [d:\ xpsp1 \admin \wmi \ wbem \ providers \ win32provider\co mmon \ implogonuser.cpp.163] 无法找到Shell Process,模拟失败。 05/06/2004 09:39:08.312主题:2540 [d:\ xpsp1 \admin\wmi \wbem \ providers \ win32provider\co mmon\implogonuser。 cpp.179]Project:----------------------------I am creating a HTTPS File Transfer App using ASP.NET and C#. I amutilizing ActiveDirectory and windows security to manage thepermissions. Why reinvent the wheel, right? Everything so far isworking well with the Active Directory. The problem I am having iswith adding File Permissions to a directory. I am currently usingsome code courtesy of "Willy Denoyette [MVP]"Problem:----------------------------When I try to add user permissions to a specific folder using the samecode in a sample console app it works correctly. When I execute thecode from ASP.NET I get a return code of 1307, everytime.Which means - 1307 This security ID may not be assigned as the ownerof this object. (http://www.hiteksoftware.com/mize/Kn...icles/049.htm).Can anyone tell me why this is happening? Willy?Environment:----------------------------I am developing with Framework 1.1 and Windows XP. The users arecoming from AD on a Windows 2003 Server.I have given ASPNET object full access to the folder C:\test. I havealso give ASPNET object full access to Root/CIMV2 inCompMgmt.msc/Services and Apps/WMI ControlCode:----------------------------The DsSettings Object is just a simple class tht contains the Loginand Path information for LDAP.public bool GrantPermission(string username, string domain, DsSettingssettings){try{byte[] bSid = (byte[])DsWrapper.GetUser(username,settings).DsEntry.Properties["objectSID"].Value;ManagementObject LogicalFileSecuritySetting = newManagementObject( new ManagementPath(@"ROOT\CIMV2:Win32_LogicalFileSecuritySetting.Path =''c:\\test''") );ManagementBaseObject outParams;outParams = LogicalFileSecuritySetting.InvokeMethod("GetSecuri tyDescriptor",null, null);ManagementBaseObject Descriptor =((ManagementBaseObject)(outParams.Properties["Descriptor"].Value));ManagementBaseObject[] DACLObject = ( ( ManagementBaseObject[] )(Descriptor.Properties["DACL"].Value ) );ManagementObject newTrusteeUser = ( new ManagementClass(@"ROOT\CIMV2:Win32_Trustee" ) ).CreateInstance();newTrusteeUser["Domain"] = domain;newTrusteeUser["Name"] = username;newTrusteeUser["SID"] = bSid;ManagementObject newACEUser = ( new ManagementClass(@"ROOT\CIMV2:Win32_Ace" ) ).CreateInstance();newACEUser["Trustee"] = newTrusteeUser;newACEUser["AceFlags"] = 3;newACEUser["AceType"] = 0;newACEUser["AccessMask"] = 2032127;// Full Access MaskManagementBaseObject[] DACLObjectNew = new ManagementBaseObject[]{newACEUser};Descriptor.Properties["DACL"].Value = DACLObjectNew;ManagementBaseObject inParams = null;inParams = LogicalFileSecuritySetting.GetMethodParameters("Se tSecurityDescriptor");inParams["Descriptor"] = Descriptor;outParams = LogicalFileSecuritySetting.InvokeMethod("SetSecuri tyDescriptor",inParams, null);// This line is where I get a result back of 1307 in ASP.NETuint result= (uint)(outParams.Properties["ReturnValue"].Value);LogicalFileSecuritySetting.Dispose();return true;}catch(Exception exp){throw exp;}}Logs:----------------------------C:\WINDOWS\system32\WBEM\Logs\Framework.log----------------------------Unable to locate Shell Process, Impersonation failed.05/06/200409:39:06.093thread:1916[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179]Shell Name Explorer.exe in Registry not found in processlist.05/06/2004 09:39:06.203thread:2540[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163]Unable to locate Shell Process, Impersonation failed.05/06/200409:39:06.203thread:2540[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179]Shell Name Explorer.exe in Registry not found in processlist.05/06/2004 09:39:07.968thread:1916[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163]Unable to locate Shell Process, Impersonation failed.05/06/200409:39:07.984thread:1916[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179]Shell Name Explorer.exe in Registry not found in processlist.05/06/2004 09:39:07.984thread:1916[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163]Unable to locate Shell Process, Impersonation failed.05/06/200409:39:08.000thread:1916[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179]Shell Name Explorer.exe in Registry not found in processlist.05/06/2004 09:39:08.093thread:1916[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163]Unable to locate Shell Process, Impersonation failed.05/06/200409:39:08.093thread:1916[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179]Shell Name Explorer.exe in Registry not found in processlist.05/06/2004 09:39:08.203thread:2540[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163]Unable to locate Shell Process, Impersonation failed.05/06/200409:39:08.203thread:2540[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179]Shell Name Explorer.exe in Registry not found in processlist.05/06/2004 09:39:08.218thread:2540[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163]Unable to locate Shell Process, Impersonation failed.05/06/200409:39:08.218thread:2540[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179]Shell Name Explorer.exe in Registry not found in processlist.05/06/2004 09:39:08.312thread:2540[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163]Unable to locate Shell Process, Impersonation failed.05/06/200409:39:08.312thread:2540[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179]推荐答案 [d:\ xpsp1 \admin \wmi \ wbem \ providers \ win32provider\co mmon \ implogonuser.cpp.179 ][d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179] [d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179 ] Shell Name Explorer.exe in Registry not found in process list. 05/06/2004 09:39:06.203 thread:2540 [d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163 ] Unable to locate Shell Process, Impersonation failed. 05/06/2004 09:39:06.203 thread:2540 [d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179 ] Shell Name Explorer.exe in Registry not found in process list. 05/06/2004 09:39:07.968 thread:1916 [d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163 ] Unable to locate Shell Process, Impersonation failed. 05/06/2004 09:39:07.984 thread:1916 [d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179 ] Shell Name Explorer.exe in Registry not found in process list. 05/06/2004 09:39:07.984 thread:1916 [d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163 ] Unable to locate Shell Process, Impersonation failed. 05/06/2004 09:39:08.000 thread:1916 [d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179 ] Shell Name Explorer.exe in Registry not found in process list. 05/06/2004 09:39:08.093 thread:1916 [d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163 ] Unable to locate Shell Process, Impersonation failed. 05/06/2004 09:39:08.093 thread:1916 [d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179 ] Shell Name Explorer.exe in Registry not found in process list. 05/06/2004 09:39:08.203 thread:2540 [d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163 ] Unable to locate Shell Process, Impersonation failed. 05/06/2004 09:39:08.203 thread:2540 [d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179 ] Shell Name Explorer.exe in Registry not found in process list. 05/06/2004 09:39:08.218 thread:2540 [d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163 ] Unable to locate Shell Process, Impersonation failed. 05/06/2004 09:39:08.218 thread:2540 [d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179 ] Shell Name Explorer.exe in Registry not found in process list. 05/06/2004 09:39:08.312 thread:2540 [d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163 ] Unable to locate Shell Process, Impersonation failed. 05/06/2004 09:39:08.312 thread:2540[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179 ] Shell Name Explorer.exe in Registry not found in process list. 05/06/2004 09:39:06.203 thread:2540[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163 ] Unable to locate Shell Process, Impersonation failed. 05/06/2004 09:39:06.203 thread:2540[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179 ] Shell Name Explorer.exe in Registry not found in process list. 05/06/2004 09:39:07.968 thread:1916[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163 ] Unable to locate Shell Process, Impersonation failed. 05/06/2004 09:39:07.984 thread:1916[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179 ] Shell Name Explorer.exe in Registry not found in process list. 05/06/2004 09:39:07.984 thread:1916[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163 ] Unable to locate Shell Process, Impersonation failed. 05/06/2004 09:39:08.000 thread:1916[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179 ] Shell Name Explorer.exe in Registry not found in process list. 05/06/2004 09:39:08.093 thread:1916[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163 ] Unable to locate Shell Process, Impersonation failed. 05/06/2004 09:39:08.093 thread:1916[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179 ] Shell Name Explorer.exe in Registry not found in process list. 05/06/2004 09:39:08.203 thread:2540[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163 ] Unable to locate Shell Process, Impersonation failed. 05/06/2004 09:39:08.203 thread:2540[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179 ] Shell Name Explorer.exe in Registry not found in process list. 05/06/2004 09:39:08.218 thread:2540[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163 ] Unable to locate Shell Process, Impersonation failed. 05/06/2004 09:39:08.218 thread:2540[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179 ] Shell Name Explorer.exe in Registry not found in process list. 05/06/2004 09:39:08.312 thread:2540[d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.163 ] Unable to locate Shell Process, Impersonation failed. 05/06/2004 09:39:08.312 thread:2540 [d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179 ][d:\xpsp1\admin\wmi\wbem\providers\win32provider\co mmon\implogonuser.cpp.179 ] 这篇关于错误1307:使用ASP.NET中的System.Management对象向NTFS添加文件权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-22 17:14