October 14, 2000

COM(+) Security: Follow-up

Introduction In my previous article [1], published atVB2TheMax site, I’ve described briefly how COM+ security and role-based securitywork. I promised you to discuss in the next article about web/IIS security;still I realized, briefly later the article was published, that some more infoabout role-based security and some general security design guide

ConvertReverseFullName – Convert a reverse name to the “FirstName LastName” format

‘ convert a reversed full name back to the “FirstName LastName” format” for example, ConvertReverseFullName(“Smith, John A.”) ==> “John A. Smith”Function ConvertReverseFullName(ByVal ReverseFullName As String) As String Dim i As Long ReverseFullName = Trim$(ReverseFullName) i = InStr(ReverseFullName, “,”) If i = 0 Then ‘ no comma, just return the argument

CamelCase – Convert a string to camel case

‘ convert a string to camel case’ for example: CamelCase(“new file name”) => “NewFileName”‘Function CamelCase(ByVal Text As String) As String Dim i As Long ‘ convert all non-alphanumeric chars to spaces For i = Len(Text) To 1 Step -1 If InStr(1, “ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789”, Mid$(Text, i, 1), _ vbTextCompare) = 0 Then

FormatPhoneNumber – Format a phone number

‘ Modify a phone-number to the format “XXX-XXXX” or “(XXX) XXX-XXXX”.Function FormatPhoneNumber(ByVal text As String) As String Dim i As Long ‘ ignore empty strings If Len(text) = 0 Then Exit Function ‘ get rid of dashes and invalid chars For i = Len(text) To 1 Step -1 If InStr(“0123456789”,

ReverseFullName – Convert a full name into the “LastName, FirstName” format

‘ reverse a full name” for example: ReverseFullName(“John A. Smith”) ==> “Smith, John A.”Function ReverseFullName(ByVal FullName As String) As String Dim i As Long ‘ search for the last space FullName = Trim$(FullName) i = InStrRev(FullName, ” “) If i = 0 Then ‘ no space, just return the argument

FormatFullName – Create a full name in the format “LastName, FirstName”

‘ Takes a first and last name and converts it to the format LastName, FirstNameFunction FormatFullName(ByVal FirstName As String, ByVal LastName As String) As _ String FirstName = Trim$(FirstName) LastName = Trim$(LastName) If FirstName = “” Then ‘ If they only have a first name, return it. FormatFullName = LastName

ConvertCamelCase – Convert from a string in camel case

‘ change a sentence in CamelCase to a sentence with spaces’ for example ConvertCamelCase(“FileExchange”) => “File Exchange”Public Function ConvertCamelCase(ByVal Value As String) As String Dim i As Long For i = 1 To Len(Trim$(Value)) ‘ If the character is uppercase, then insert a space before If Asc(Mid$(Value, i, 1)) =

FormatCreditCard – Format a credit card number

‘ Format a credit card numberFunction FormatCreditCard(ByVal text As String) As String Dim i As Long ‘ ignore empty strings If Len(text) = 0 Then Exit Function ‘ get rid of dashes, spaces and invalid chars For i = Len(text) To 1 Step -1 If InStr(“0123456789”, Mid$(text, i, 1)) =