bool IServerConfig.GetUncUser(IApplicationHost appHost, VirtualPath path, out string username, out string password)
        {
            bool flag = false;

            username = null;
            password = null;
            IntPtr zero         = IntPtr.Zero;
            int    cchUserName  = 0;
            IntPtr bstrPassword = IntPtr.Zero;
            int    cchPassword  = 0;

            try
            {
                if (UnsafeIISMethods.MgdGetVrPathCreds(IntPtr.Zero, appHost.GetSiteName(), path.VirtualPathString, out zero, out cchUserName, out bstrPassword, out cchPassword) == 0)
                {
                    username = (cchUserName > 0) ? StringUtil.StringFromWCharPtr(zero, cchUserName) : null;
                    password = (cchPassword > 0) ? StringUtil.StringFromWCharPtr(bstrPassword, cchPassword) : null;
                    flag     = !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password);
                }
            }
            finally
            {
                if (zero != IntPtr.Zero)
                {
                    Marshal.FreeBSTR(zero);
                }
                if (bstrPassword != IntPtr.Zero)
                {
                    Marshal.FreeBSTR(bstrPassword);
                }
            }
            return(flag);
        }
 bool IServerConfig.GetUncUser(IApplicationHost appHost, VirtualPath path, out string username, out string password)
 {
     bool flag = false;
     username = null;
     password = null;
     IntPtr zero = IntPtr.Zero;
     int cchUserName = 0;
     IntPtr bstrPassword = IntPtr.Zero;
     int cchPassword = 0;
     try
     {
         if (UnsafeIISMethods.MgdGetVrPathCreds(IntPtr.Zero, appHost.GetSiteName(), path.VirtualPathString, out zero, out cchUserName, out bstrPassword, out cchPassword) == 0)
         {
             username = (cchUserName > 0) ? StringUtil.StringFromWCharPtr(zero, cchUserName) : null;
             password = (cchPassword > 0) ? StringUtil.StringFromWCharPtr(bstrPassword, cchPassword) : null;
             flag = !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password);
         }
     }
     finally
     {
         if (zero != IntPtr.Zero)
         {
             Marshal.FreeBSTR(zero);
         }
         if (bstrPassword != IntPtr.Zero)
         {
             Marshal.FreeBSTR(bstrPassword);
         }
     }
     return flag;
 }
 // if appHost is null, we use the site name for the current application
 string IServerConfig.MapPath(IApplicationHost appHost, VirtualPath path) {
     string siteName = (appHost == null) ? _siteNameForCurrentApplication : appHost.GetSiteName();
     string physicalPath = ProcessHostConfigUtils.MapPathActual(siteName, path);
     if (FileUtil.IsSuspiciousPhysicalPath(physicalPath)) {
         throw new InvalidOperationException(SR.GetString(SR.Cannot_map_path, path.VirtualPathString));
     }
     return physicalPath;
 }
        string IServerConfig.MapPath(IApplicationHost appHost, VirtualPath path)
        {
            string siteName     = (appHost == null) ? this.CurrentAppSiteName : appHost.GetSiteName();
            string physicalPath = this._nativeConfig.MapPathDirect(siteName, path);

            if (FileUtil.IsSuspiciousPhysicalPath(physicalPath))
            {
                throw new InvalidOperationException(System.Web.SR.GetString("Cannot_map_path", new object[] { path.VirtualPathString }));
            }
            return(physicalPath);
        }
Пример #5
0
        bool IServerConfig.GetUncUser(IApplicationHost appHost, VirtualPath path, out string username, out string password)
        {
            bool foundCreds = false;

            username = null;
            password = null;

            IntPtr pBstrUserName = IntPtr.Zero;
            int    cBstrUserName = 0;
            IntPtr pBstrPassword = IntPtr.Zero;
            int    cBstrPassword = 0;

            try {
                int result = UnsafeIISMethods.MgdGetVrPathCreds(IntPtr.Zero,
                                                                appHost.GetSiteName(),
                                                                path.VirtualPathString,
                                                                out pBstrUserName,
                                                                out cBstrUserName,
                                                                out pBstrPassword,
                                                                out cBstrPassword);
                if (result == 0)
                {
                    username   = (cBstrUserName > 0) ? StringUtil.StringFromWCharPtr(pBstrUserName, cBstrUserName) : null;
                    password   = (cBstrPassword > 0) ? StringUtil.StringFromWCharPtr(pBstrPassword, cBstrPassword) : null;
                    foundCreds = (!String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(password));
                }
            }
            finally {
                if (pBstrUserName != IntPtr.Zero)
                {
                    Marshal.FreeBSTR(pBstrUserName);
                }
                if (pBstrPassword != IntPtr.Zero)
                {
                    Marshal.FreeBSTR(pBstrPassword);
                }
            }

            return(foundCreds);
        }
Пример #6
0
 public IRegisteredObject CreateObject(IApplicationHost appHost, Type type)
 {
     if (appHost == null)
         throw new ArgumentNullException("appHost");
     if (type == null)
         throw new ArgumentNullException("type");
     string appId = CreateSimpleAppId(VirtualPath.Create(appHost.GetVirtualPath()), appHost.GetPhysicalPath(), appHost.GetSiteName());
     return CreateObjectInternal(appId, type, appHost, false);
 }
 private string CreateSimpleAppID(IApplicationHost appHost)
 {
     if (appHost == null)
     {
         throw new ArgumentNullException("appHost");
     }
     return this.CreateSimpleAppID(VirtualPath.Create(appHost.GetVirtualPath()), appHost.GetPhysicalPath(), appHost.GetSiteName());
 }
Пример #8
0
        // if appHost is null, we use the site name for the current application
        string IServerConfig.MapPath(IApplicationHost appHost, VirtualPath path)
        {
            string siteName     = (appHost == null) ? _siteNameForCurrentApplication : appHost.GetSiteName();
            string physicalPath = ProcessHostConfigUtils.MapPathActual(siteName, path);

            if (FileUtil.IsSuspiciousPhysicalPath(physicalPath))
            {
                throw new InvalidOperationException(SR.GetString(SR.Cannot_map_path, path.VirtualPathString));
            }
            return(physicalPath);
        }
        bool IServerConfig.GetUncUser(IApplicationHost appHost, VirtualPath path, out string username, out string password) {
            bool foundCreds = false;
            username = null;
            password = null;

            IntPtr pBstrUserName = IntPtr.Zero;
            int cBstrUserName = 0;
            IntPtr pBstrPassword = IntPtr.Zero;
            int cBstrPassword = 0;

            try {
                int result = UnsafeIISMethods.MgdGetVrPathCreds( IntPtr.Zero,
                                                                 appHost.GetSiteName(),
                                                                 path.VirtualPathString,
                                                                 out pBstrUserName,
                                                                 out cBstrUserName,
                                                                 out pBstrPassword,
                                                                 out cBstrPassword);
                if (result == 0) {
                    username = (cBstrUserName > 0) ? StringUtil.StringFromWCharPtr(pBstrUserName, cBstrUserName) : null;
                    password = (cBstrPassword > 0) ? StringUtil.StringFromWCharPtr(pBstrPassword, cBstrPassword) : null;
                    foundCreds = (!String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(password));
                }
            }
            finally {
                if (pBstrUserName != IntPtr.Zero) {
                    Marshal.FreeBSTR(pBstrUserName);
                }
                if (pBstrPassword != IntPtr.Zero) {
                    Marshal.FreeBSTR(pBstrPassword);
                }
            }

            return foundCreds;
        }
 string IServerConfig.MapPath(IApplicationHost appHost, VirtualPath path)
 {
     string siteName = (appHost == null) ? this.CurrentAppSiteName : appHost.GetSiteName();
     string physicalPath = this._nativeConfig.MapPathDirect(siteName, path);
     if (FileUtil.IsSuspiciousPhysicalPath(physicalPath))
     {
         throw new InvalidOperationException(System.Web.SR.GetString("Cannot_map_path", new object[] { path.VirtualPathString }));
     }
     return physicalPath;
 }
Пример #11
0
        public IRegisteredObject CreateObject(IApplicationHost appHost, Type type)
        {
            if (appHost == null)
            {
                throw new ArgumentNullException("appHost");
            }
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            string appId = CreateSimpleAppId(VirtualPath.Create(appHost.GetVirtualPath()), appHost.GetPhysicalPath(), appHost.GetSiteName());

            return(CreateObjectInternal(appId, type, appHost, false));
        }