Tuesday, May 26, 2009

Basic LDAP Search query

  • = (EQUAL TO) 
    This LDAP argument means a certain attribute must be equal to a certain value to be true. For example, if you want to find all objects that have the first name of John, you would use:
    (givenName=John) 
    This would return all objects that have the first name of John. Parentheses are included to emphasize the beginning and end of the LDAP statement.
  • & (logical AND) 
    You use this syntax when you have more than one condition, and you want all conditions in the series to be true. For example, if you want to find all of the people that have the first name of John and live in Dallas, you would use:
    (&(givenName=John)(l=Dallas)) 
    Notice that each argument is in its own set of parentheses. The entire LDAP statement must be encompassed in a main set of parentheses. The & operator means that each argument must be true for this filter to apply to your object in question.
  • ! (logical NOT) 
    This operator is used to exclude objects that have a certain attribute. Suppose you need to find all objects except those that have the first name of John. You would use the following statement:
    (!givenName=John) 
    This statement would find all objects that do not have the first name of John. Notice that the ! operator goes directly in front of the argument and inside the argument's set of parentheses. Because there is only one argument in this statement, it is surrounded with parentheses for illustration.
  • * (wildcard) 
    You use the wildcard operator to represent a value that could be equal to anything. One such situation might be if you wanted to find all objects that have a value for title. You would then use:
    (title=*) 
    This would return all objects that have the title attribute populated with a value. Another example might be if you know an object's first name starts with Jo. Then, you could use the following to find those:
    (givenName=Jo*) 
    This would apply to all objects whose first name starts with Jo.
  • The following are more advanced examples of LDAP syntax:
    • You need a filter to find all objects that are in Dallas or Austin, and that have the first name of John. This would be:
      (&(givenName=John)(|(l=Dallas)(l=Austin))) 
    • You have received 9,548 events in the Application log, and you need to find all of the objects that are causing this logging event. In this case, you need to find all of the disabled users (msExchUserAccountControl=2) that do not have a value for msExchMasterAccountSID. This would be:
      (&(msExchUserAccountControl=2)(!msExchMasterAccountSID=*)) 
    Aa996205.note(en-us,EXCHG.65).gifNote:
    The ! operator in conjunction with the wildcard operator will look for objects where that attribute is not set to anything.

Getting Date Time Format Lotus TDI

Problem Statement:
When adding a record in a Lotus Notes database via Lotus Notes
Connector, how do you set a Time/Date data type field?

It appears, by default the field will be set as text string and not
Time/Date data type.

I tried to use java.util.Calendar and other similar date classes like
java.util.Date, etc but when I do that the Lotus Notes connector
throws an exception.
NotesException: Unknown or unsupported object type in Vector
       at lotus.domino.local.Document.NreplaceItemValue(Native Method)
       at lotus.domino.local.Document.replaceItemValue(Unknown Source)
       at com.ibm.di.connector.DominoConnector.modDocument(Unknown Source)
       at com.ibm.di.connector.DominoConnector.putEntry(Unknown Source)
       at com.ibm.di.server.AssemblyLineComponent.add1(Unknown Source)
       at com.ibm.di.server.AssemblyLineComponent.add(Unknown Source)
       at com.ibm.di.server.AssemblyLine.msExecuteNextConnector(Unknown
Source)
       at com.ibm.di.server.AssemblyLine.executeMainStep(Unknown Source)
       at com.ibm.di.server.AssemblyLine.executeMainLoop(Unknown Source)
       at com.ibm.di.server.AssemblyLine.executeMainLoop(Unknown Source)
       at com.ibm.di.server.AssemblyLine.executeAL(Unknown Source)
       at com.ibm.di.server.AssemblyLine.run(Unknown Source)

Solution :
Date: Sat, May 23 2009 3:30 am
From: Eddie Hartman


This is how you catch one like this:

The Connect and Read Next buttons in Input and Output Maps is
the key. Now if you are using Local Client connection to TDI, then
you are unable to use this feature [solution to follow -ed]. When you
discover data this way, you also get the Java class returned by
the Notes library. Then you know what kind of Java object to
create for the value to make this write operation work. In your
case it's lotus.domino.cso.DateTime.

Google lead me to this link:
http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/topic/com.ibm.help.domino.designer85.doc/DOC/H_JAVA_NOTES_CLASSES_JAVA.html" target="_blank" style="color: rgb(61, 84, 89); http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/topic/com.ibm.help.domino.designer85.doc/DOC/H_JAVA_NOTES_CLASSES_JAVA.html

The "A-Z Reference" link takes you to the DateTime class. When you
click through you find that there's a section on creation (like for
all Domino classes):

...
Creation

To create a new DateTime object, use createDateTime in Session.
...

So all you need is the Domino session, which your Notes Connector
is holding for you. You request it using the getDominoSession()
method.
It's documented in the TDI JavaDocs (Help > Low Level API) under the
DominoConnector class. Of course, how do you know which class to look
up? For example, "system" object is the "UserFunctions" class...
The answer here is to ask TDI -- but I'll get back to that in a
moment.

First off, once you know the object and how to make one, it's simple:

JavaScript Attribute Map for "EventTime" (unabridged version :):
-----------------------------------------------------------------------------------
  // Get the com.ibm.di.connector.DominoConnector object
  notesConnectorInterface = thisConnector.getConnector();

  // Now get the session from it.
  notesSession = notesConnectorInterface.getDominoSession();

  // Grab the EventTime attribute value (must be java.util.Date)
  // If not, then you need to convert it. system.parseDate()
  // is handy for turning formatted Strings to Dates.
  eventTime = work.getObject("EventTime");

  // Now create the Notes DateTime object
  dEventTIme = notesSession.createDateTime(eventTIme);

  // Return this for the value of the mapping rule
  ret.value = dEventTime;

Easy as spittin'.

Now getting back to figuring out what classes you're dealing
with:

Have an AL (I always call mine "1_Test" so it sorts first) and drop
in a Notes Iterator, using any session type. Then start it up in
Step / Paused mode, launching the debugger. Once you get control
back, step to the After GetNext Hook (either by right-clicking and
choosing "Run and break here", clicking the Breakpoint checkbox next
to it and press the "Continue" button, or just step you way down
and watch how TDI works under the covers :)

Once you are in the After GetNext Hook, then there is data in
conn. In the JavaScript commandline (the long input field next to
the scissor button) enter the following:

  conn.getObject("EventTime").getClass()

and press Enter. Each time you press Enter, the snippet of script
you typed is send to the running TDI Server (even if you connect
to a remote one) and executed in the context of your AL. You can
examine and define variables, execute functions or manipulate data.
This lets you easily drive execution along the path you want it to
take. And it lets you exercise Java api's interactively. Very sweet :)

There is a video on the Debugger here:
http://www.tdi-users.org/twiki/bin/view/Integrator/LearningTDI#DebuggerVideo

Furthermore, you can use Document Selection parameter to
filter the documents returned. For example, if you have the UNID
of a particular Document of the type you want to examine, just
enter this search formula:

  UNID=xxxxxxxx

With no quotes. You do have to quote text field filter values, and
surround dates with brackets. A little experemintation taught me
this. NOTE: if anyone out there has a link to docs or examples,
_please_ share.

Hope this helps!

-Eddie

Tuesday, May 12, 2009

Creating JavaScript Functions

If i have 3 work attributes say : 

Name , title , brand , and i want brand to be processed according to some predefined set of instructions, then the steps required to accompalish the same are : 

1. In the brand work attribute , select the type attribute as "Advanced Javascript".

Add the following line to the javascript window:

ret.value = myScript(conn); 

Now we need to define the function myScript. We are passing the current object in the same. 

2. Go to Scripts on the left, and right click.  Select New Script, and give it a name. This is not the script function, but we will we writing our script in it. 

Now, we have to make our function:

Copy the following code : 

function myScript(conn)
{
var n = conn.getAttribute("Name");

if (n !=null || n.toString()=="Deepak")
e = n; 
else 
e = conn.getAtribute("Name");
return e;

}

We are nearly done. If you try to run the program now, you will certainly have to deal with an incorrect code. 

3. go to script function. select the config tab ,and check the check box -> implict included. 

Run the program. 

Yout javascript function is ready.

any errors/feedback/queries, drop a comment

Monday, May 4, 2009

Risk Assessment

Risk Assessment can be done in many ways : 
1. Transfer Risk
2. Mitigate Risk
3. Accept Risk
4.Ignore Risk

Risk is an important way to assess the need for enterprise security. If we dont assess the risks , we will not understand the costs involved , and the security costs will always be on higher end. So we should access the risks properly. 
IBM Tivoli helps you to assess the risk, and go out with the correct resources and conquer any secutiy threat.