Archive for August, 2008

Validate email address (LotusScript)

Yesterday I spent some time on googling looking for a decent LS function that validates an email internet address. 

The evaluate method on

@ValidateInternetAddress( [ addressFormat ] ; Address )

validates only on characters before and after the @ sign, so it does not check the top level domain (.com, .org or .se) and was therefor of no use.

Well, what did Google bring me then? Nothing of interest unfortunately.

Tomas sent me the function below but when testing it it does not properly checked if a username is given (‘@acme.com’ would validate).

A simple combination of these two checks will do the job but this looks a bit poor. Maybe you have a better solution?

Function CheckSMTPAddressChar( smtpAddress As String) As Boolean
%REM - Check to see if any incorrect characters is used in the SMTP address
smtpAddress  : the SMTP address to validate
return    : will return true if valid email address
%END REM
 Dim notAllowed As Variant
 Dim noNotAllowed As Integer
 Dim char As String
 Dim charNum As Integer
 Dim noAtChar As Integer
 Dim i As Integer
 
 CheckSMTPAddressChar = True
 
 For i = 1 To Len( smtpAddress)
  char = Mid( smtpAddress, i, 1)
  If char = ” ” Then char = “<space>”
  charNum = Asc( char)
  REM  No local characters is allowed only … normal once
  Select Case charNum
  Case 65 To 90  ’ 65 = a, 90 = z
  Case 97 To 122  ’ 97 = A, 122 = Z
  Case 48 To 58  ’ 48 = 0, 58 = 9
  Case 45    ’ 45 = -
  Case 46    ’ 46 = .
  Case 64    ’ 64 = @
  REM  We can have 1 char 46 = @ but not 2
   noAtChar = noAtChar + 1
   If noAtChar > 1 Then
    CheckSMTPAddressChar = False
   End If
  Case 95    ’ 57 = _
  Case Else
   CheckSMTPAddressChar = False
  End Select
 Next
End Function

===//===

Dim smtpAddress As String
 smtpAddress = “patrick.kwinten@acme.com
 If CheckSMTPAddressChar(smtpAddress) And smtpAddress Like “*@*.*” Then
  ’do a double check
  Dim emailChecker As Variant
  Dim checkThis()
  Redim checkThis(0)
  checkThis(0) = smtpAddress
  emailChecker = Evaluate(|@ValidateInternetAddress([Address821];”| + checkThis(0) + |”)|)
  If emailChecker(0) = “” Then
   Print “Valid Email address!”
  Else
   Print “Email address not valid!”
  End If    
 Else
  Print “Email address not valid!”
 End If
End Sub

Comments (4)

The debugger is bugging me

I don’t know why but for one certain application the Continue, Step into etcetera buttons are not displayed any more in the LotusScript debugger. I googled but I could not find an answer to ‘reset’ it. Do you know THE solution?

error in debugger

error in debugger

PS. I use the Notes 7 client…

Comments (4)

Combine column lookups

Hejsan. I will pick the quickest way to post something in the SNTT category by just adding an image which explains itself. It is probably taken from a LotuSphere session (guess the session?).

I recently used in in updating an application that was dated somewhere from 1998 and used @DBColumns in a form more than 30 times, so adding this technique was a major performance improvement…

combining multiple dbcolumns

combining multiple dbcolumns

Comments (1)

A (different) document security model

One of the reasons why everyone in my company says I am a lovable chap is because I give technical support on an important HR application. In this application HR keeps track of the top-level functions in our organisation (Position), who is currently on a function (Successor) and who are marked as possible follow-ups (High Potential).

Since I am one of the few people who can read all information in the database occassionaly I receive the question if I have seen one’s name listed. Well try again next time if you see me in the pub. Maybe if you offer me a beer you might have more luck then, is my reply. Unfortunately this has not resulted (yet) in any free drinks…

The security model in this application works like this:

  • people in the a higher level in the organisation may read all documents underneath their own level
  • people in a lower level in the organisation may not read any documents above their own level

I must also mention how application security is distributed in our organisation:

  • The Domino directory contains for each application a default set of usergroups. These groups represent the level people get in the ACL (reader, author, editor, designer)
  • For server related groups their is a group for editor and manager access
  • For each role a separate usergroup is listed

The naming of a usergroups is as followed:

  • filename_typeofuser_accesslevel

Examples of groupnames are:

  • SA01232_Users.Author
  • SA01232_Users.Designer
  • SA01232_Server.Manager
  • SA01232_Roles.Admin

There is a routine running that creates for each role a group in the Directory and an application administrator can assign users to a group by assigning a user a role.

This works all fine BUT there is a limitation how many roles an ACL may contain (75 according to the Help).

My HR application is from a pre-standards age and has a slightly different security model that is based on individual usergroups that represent an organisational structure like in:

  • filename_typeofuser_accesslevel_orglevel1_orglevel2… up till orglevel6

Therefor every position document in the application will get its unique usergroup reference and also all the usergroups of positions higher in the organisation.

For example the position document for the manager of Acme\Europe\Sales\Invoice also get the usergroups of Acme\Europe\Sales, Acme\Europe and Acme so the head of Sales, Europe can nominate and see who are in the pool of potentials for following up the head of Invoice, Sales, Europe.

Nothing to worry about except that the write access to the Domino directory is (wisely) restricted for normal users. So everytime someone thinks a usergroup needs to be updated a request has to be send to an administrator, and the updating is still then a manual task…

Well why would I worry? My worries came in the picture as soon as the application that is being used to administrate user access did not any longer display proper information about who has access to what level.

Since this an application with a one of a kind security model I could not expect any support from the administrators, they were more than happy to emphasize that it was about time that I write the security model to the model we have as standard.

Due to the limitation of userroles in an ACL I was forced to look for alternatives and one is to maintain the usergroup in the application itself and not care about having the usergroups any more in the Domino directory. This would also give me the opportunity to apply some new features like applying a mechanism to update the usergroups by the application administrator.

This all sounded nice, but a lot of work on uncovered terrain untill the sun started to shine outside when I discovered Ulriche Krause’s posting ‘Is User A Member Of A (Nested) Group ?‘.

This function allowed to copy the usergroups into my application and do the calculation from within. As a result I will get an array with usernames which I then could apply in Readers and Authors fields on each document.

I know this is data overhead (usernames stored in stead of usergroups) for something normally the Domino directory takes care of but for my application I consider it the best solution. Or am I wrong?

Note: I have added a scheduled routine that sets a flag on an updated usergroup. For each updated usergroup document the following routine runs:

Sub Initialize
 
 Dim ses As New NotesSession
 Dim luView As NotesView
 Dim groupView As NotesView
 Dim groupDoc As NotesDocument
 Dim dc As NotesDocumentCollection 
 Dim doc As NotesDocument
 
 Set db = ses.CurrentDatabase 
 Set groupView = db.GetView(“luGroup”)
 Set luView = db.GetView(“luDocsByGroup”)
 Set groupDoc = groupView.GetFirstDocument
 
 Do Until groupDoc Is Nothing
  If groupDoc.Tx_GroupUpdated(0) = “1″ Then
   ’Group document updated – update all position and successor documents containing the group
   Set dc = luView.GetAllDocumentsByKey(groupDoc.ListName(0), True)
   Set doc = dc.GetFirstDocument
   Do Until doc Is Nothing
    Call UpdateDocumentAccess(doc)
    Set doc = dc.GetNextDocument(doc)
   Loop
  End If
  groupDoc.Tx_GroupUpdated = “0″
  Call groupDoc.save(True,False,False)
  Set groupDoc = groupView.GetNextDocument(groupDoc)
 Loop
 
End Sub

View luGroup contains all the usergroup documents, View luDocsByGroup contains all documents (Position, Successor, High Potential) that might need to be updated.

To ‘monitor’ if an usergroup is updated I use:

Sub Postopen(Source As Notesuidocument)
 membersPO = Join(source.Document.Members, “##”)
End Sub

and

Sub Postsave(Source As Notesuidocument)
 
 Dim groupChanged As String
 Dim membersPS As Variant
 membersPS = Join(source.Document.Members, “##”)
 If membersPO <> membersPS Then
  source.Document.Tx_GroupUpdated = “1″
  Call source.Document.Save(True,True,True)
 End If
 
End Sub

That’s for now, I go out cause the sun has started shining again!

Leave a Comment

Design coding – in rap

Thank Yourself it’s Friday!

This week was my first week at the office after a vacation period so lets end this week right with some fun. Finally a rap not about money, bitches or bling bling.

Leave a Comment

Hide paragraph if formula is true – HTML comment

The one thing I hate about the ‘hide paragraph if…’ feature is that, without opening the text properties box and navigate to the fifth tab, you hardly can tell if the paragraph is hidden or displayed and for which system (Notes client, Mobile or Web client).

In order to save some time and make it more visual I decided to add some HTML comment tagging saying that this piece of paragraph is hidden (or when conditional what the formula is).

Maybe you have a better suggestion?

hide when paragraph

Comments (6)