Error message 401.3: You do not have permission to view this directory or page using the credentials you supplied (access denied due to Access Control Lists)

Keep getting the following error when trying to access the website running on Anonymous Authentication?

“Error message 401.3: You do not have permission to view this directory or page using the credentials you supplied (access denied due to Access Control Lists)”

IIS_error

Solution:

  • Go to Internet Information Services Manager (cmd : inetmgr)
  • Select the website / Application
  • Double click on “Authentication” feature on the right hand side pane

auth

  • Select “Anonymous Authentication” and click on “Edit” action

editAuth

  • By default the identity would be something like “IUSR”, “IIS_IUSR”, etc…

selectUser

  • At this point you could specify a specific user or just select the “Application pool identity” option and go with the default application pool identity.
  • The application pool identity userid would be in the form of “IIS APPPOOL\{Application Pool Name}”.

For example:

If the application pool name is “DefaultAppPool”, then the application pool identity             userid would be IIS APPPOOL\DefaultAppPool.

  • After selecting the Anonymous Authentication Credentials, select the website / application folder and go to the security/permissions tab in the folder properties

editPermission

  • Add the userid / application pool userid in to the permissions and give appropriate permissions to the userid. In case where you want to specify the application pool identity userid. Change the “Location” to the local computer, type in the application pool identity userid and click “OK”, do not try to “Check Names” for this userid as you may not find it anywhere.

assignPermissions

  • Click “OK”, select the appropriate permissions and click “Apply”
  • Click “OK” twice
  • Done!!

There is no EventLog source named ‘ASP.NET x.x.x.’. This module requires .NET Framework x.x

There is no EventLog source named ‘ASP.NET x.x.x.’. This module requires .NET Framework x.x

The above error is thrown because we are trying to log the ASP.Net errors (in most cases, unhandled errors) in to EventLog of the O/S using “WebMonitor.UnhandledExceptionModule” but the required EventLog source is missing. Therefore the fix for this would be to create the missing EventLog source. But where? Below I explain where and how to create the missing EventLog source in the server that you have hosted your site.

Where?

The missing EventLog source should be created in the O/S registry at the following location;

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet001\Services\EventLog\Application

How?

  1. Open the O/S registry by executing the “regedit” command in the “Run”
  2. Browse to the above location in the O/S registry, if there’s already an EventLog source which is pointing to the same .Net Framework as the one your application is running on, then export that key as shown in the screenshot below;

regexport

  1. Then open the exported *.reg file and change the Key name to the missing EventLog source shown in the error message as shown in the screenshot below and save the file;

editexport

  1. Go back to O/S registry again and import the edited *.reg file;

regimport

That’s it, this should fix the issue for you!! If not pls let me know

MS SQL Server Stored Procedure Search

Hi All,

Recently I had to write the following script on MS SQL Server to create a proc that would search through all the procedures in the database for a given search phrase. Guess it would be helpful for someone else as well.

create proc adm_SearchProcs
@searchText varchar(max)
as
begin
select ‘exec sp_helptext ‘ +””+ specific_schema +’.’ + routine_name +””
from information_schema.routines
where routine_definition like ‘%’+@searchText+’%’
order by 1
end

Happy Coding!!

Rasika

How to resolve SQL Server 2005 Index Corrupt issue

Hi All,

I recently came across the following errors on trying to do an integrity check on one of my DBs

Msg 8951, Level 16, State 1, Line 1
Table error: table ‘LIVE.CBNHEA’ (ID 1652916960). Data row does not have a matching index row in the index ‘CBNHEA_ROWID’ (ID 2). Possible missing or invalid keys for the index row matching:
Msg 8955, Level 16, State 1, Line 1
Data row (1:3726817:1) identified by (HEAP RID = (1:3726817:1)) with index values ‘ROWID = 5679187 and HEAP RID = (1:3726817:1)’.
Msg 8951, Level 16, State 1, Line 1
Table error: table ‘LIVE.CBNHEA’ (ID 1652916960). Data row does not have a matching index row in the index ‘CBNHEA_CBH0’ (ID 3). Possible missing or invalid keys for the index row matching:
Msg 8955, Level 16, State 1, Line 1
Data row (1:3726817:1) identified by (HEAP RID = (1:3726817:1)) with index values ‘STOFCY_0 = ‘HLT’ and ITMREF_0 = ‘ and HEAP RID = (1:3726817:1)’.
Msg 8951, Level 16, State 1, Line 1
Table error: table ‘LIVE.CBNHEA’ (ID 1652916960). Data row does not have a matching index row in the index ‘CBNHEA_CBH1’ (ID 4). Possible missing or invalid keys for the index row matching:
Msg 8955, Level 16, State 1, Line 1
Data row (1:3726817:1) identified by (HEAP RID = (1:3726817:1)) with index values ‘STOFCY_0 = ‘HLT’ and LLC_0 = 99 and ITMREF_0 = ‘ and HEAP RID = (1:3726817:1)’.
CHECKDB found 0 allocation errors and 3 consistency errors in table ‘LIVE.CBNHEA’ (object ID 1652916960).
CHECKDB found 0 allocation errors and 3 consistency errors in database ‘xxxxx’.
repair_rebuild is the minimum repair level for the errors found by DBCC CHECKDB (xxxxx).

Then I ran the dbcc CHECKDB with ‘repair_rebuild’ on single user mode and it fixed the issue straight away.

This is what I did;

1. Put the DB on single user mode – In order to do this, right-click on the DB and select properties and then go to options, in the options select “Restrict Access” and then select “Single_User” and click “Yes”. You will have to close the management studio and reconnect again before proceeding to the next step.

2. After login on to management studio open up a query window that points to the relevant DB. Type the following

dbcc CHECKDB(‘dbname’,‘repair_rebuild’)

3. run the dbcc CHECKDB(‘dbname’)

This time all the inconsistency errors are gone 🙂

Happy Coding 🙂

Regex replace for MySQL

Hi All,

Recently I came across a requirement where I had to cleanse the data that I’m inserting in to MySQL database using regular expressions, so I started searching for a function to do this on MySQL, but unfortunately I couldn’t find any. There was one called UDB but that’s also you need to install a module and stuff like that. I gave up searching finally and wrote my own “regex_replace” MySQL function.

Below is the source code of my function;

DELIMITER $$
CREATE FUNCTION  `regex_replace`(pattern VARCHAR(1000),replacement VARCHAR(1000),original VARCHAR(1000))

RETURNS VARCHAR(1000)
DETERMINISTIC
BEGIN 
 DECLARE temp VARCHAR(1000); 
 DECLARE ch VARCHAR(1); 
 DECLARE i INT;
 SET i = 1;
 SET temp = '';
 IF original REGEXP pattern THEN 
  loop_label: LOOP 
   IF i>CHAR_LENGTH(original) THEN
    LEAVE loop_label;  
   END IF;
   SET ch = SUBSTRING(original,i,1);
   IF NOT ch REGEXP pattern THEN
    SET temp = CONCAT(temp,ch);
   ELSE
    SET temp = CONCAT(temp,replacement);
   END IF;
   SET i=i+1;
  END LOOP;
 ELSE
  SET temp = original;
 END IF;
 RETURN temp;
END$$
DELIMITER ;

Note:

If you are using MySQL version 5.0.1 or higher, make sure you set the NO_BACKSLASH_ESCAPES mode ON, before you use the above function to replace any characters which are escaped with back slash “\”, ie: \A,\B,etc… See how to set the NO_BACKSLASH_ESCAPES mode here

Example on how to use this function
mysql> select regex_replace('[^a-zA-Z0-9\-]','','2my test3_text-to. check \\ my- sql (regular) ,expressions ._,');

Happy Coding!! 🙂

DBNull Parser for VBScript

Function ParseDBNull(objVal,strDataType)

         If ISNull(objVal) = True Then

               Select Case  lcase(strDataType)

                           Case “string”,”datetime”

                                       ParseDBNull = “”

                          Case “numeric”

                                    ParseDBNull = 0

                         Case “boolean”

                                    ParseDBNull = False

                         Case Else

                                     ParseDBNull = “”

                    End Select

             Else

                      ParseDBNull = objVal

              End If

End Function

Adding PopUpMenu Items dynamically to the DataGrid’s PopUpMenu in SalesLogix6.2

Hi All,

You can use the following method to add menu items dynamically to the PopUpMenu of the DataGrid control of the SalesLogix6.2 LAN Client.

Sub PupulateMenu()

dim objMnu,i
dim arrMenuItems

 arrMenuItems = Array(“Menu Item1″,”Menu Item2″,”Menu Item3″,”Menu Item4”)
 set objMnu = <DataGrid Control Name>.PopupMenu

 For i=0 to Ubound(arrMenuItems)
 objMnu.Add
 objMnu.Items(i+1).Caption = arrMenuItems(i)
 Next

End Sub

Sub <DataGrid Control Name>MenuClick(Sender,Item) 

Select case  <DataGrid Control Name>.PopupMenu.MenuIndex
        case 1
             msgbox “Menu Item1 Selected”
        case 2
             msgbox “Menu Item2 Selected”
        case 3
             msgbox “Menu Item3 Selected”
        case 4
             msgbox “Menu Item4 Selected”
        case else
             msgbox “Invalid Menu Option”
 End Select

End Sub

Happy Coding!! 🙂