Powershell and Lotus Notes - How to extract user names with employees numbers? - powershell

I have specific problem. I need to extract domain names from active directory and combine them with employees numbers which are in Lotus Notes. I get the domain names with Get-QADUser (snapin from quest.com), that was no problem, but how to get the employees numbers and combine them? Thank you
Edit(18.5. 11:56): Now I'm using this script (posted by Christian) and I figured out how to get the name of LN database - right-click on DB in Lotus notes workspace, then application/properties.
# Create LN Object
$DomSession = New-Object -ComObject Lotus.NotesSession
# Initialize LN Object
# You'll be asking for LN password to your id
$DomSession.Initialize()
# Connect to Server, select db and display the name
$DomDatabase = $DomSession.GetDatabase("LN007","IT\HW.nsf")
Write-Host "Database open : " $DomDatabase.Title
# Open specific View (By Serial Number)
$DomView = $DomDatabase.GetView('Serial Number')
Write-Host "View read : " $DomView.Name
# Show number of documents
$DomNumOfDocs = $DomView.AllEntries.Count
Write-Host "Num of Docs : " $DomNumOfDocs
# Get First Document in the View
$DomDoc = $DomView.GetFirstDocument()

If you have access to the database and a Notes client, you can open the database in Notes Designer and review what views are available. You should then be able to find one or create one that contains the data you need.
If you don't have access to Lotus Notes, you're close enough with your powershell script that you can use the com API to get the information. The NotesDatabase object (i.e. $DomDatabase) has a Views property which will return NotesView objects. You can iterate over those and print out the names as a start. Likewise once you've found the view you want, you can access the columns within that view using the NotesView's Columns property.
You'll want to check out the COM api docs here for more help: http://blagoevgrad.court-bg.org/help/help85_designer.nsf/Main?OpenFrameSet (see the section LotusScript/COM/OLE Classes)
Depending on how comfortable you are with Powershell vs the com api, you could probably handle this a few ways, either by extracting all the documents in the view and getting the data out, or perhaps using the built in NotesView.GetDocumentByKey method that would act as a lookup in your script. With a view sorted on the key you're querying on (and set as your view's first column), you could call that method and get back the document with that key. Then use that NotesDocument object to retrieve any value within it (i.e. the employee name or number or whatever)

You can retrieve data from Lotus Notes using com object.
Suggested links:
http://davidmoravec.blogspot.it/2008/08/retrieve-data-from-lotus-notes-with.html
Lotus Notes comobject

Is the database you are opening called "names.nsf" by any chance? If so, that's the standard Domino Directory database and you should be using the "People" view, and the item name you are looking for should be "EmployeeID" -- unless the customer has customized the database with their own field names.
If it is a custom database you are working with, then in addition to using the Notes client and Domino Designer, get yourself a copy of NotesPeek. It's free. Download here
It gives you a tree view of the database. It shows you everything that is stored in the database -- but it only shows you what is stored, so computed fields that you can see in the Notes client but aren't accessible through the Notes classes won't confuse you. (The document properties dialog in the Notes client won't show you computed values either if you use it while you have a document selected in a view, but it will show them to you if you use while you have a document actually open.)

Related

Automatically download emails from Outlook with SAS or Outlook rule

I am trying to create a program to automatically download the attached files that are sent to us from a certain email and then transform the delimiter with SAS, of those csv that are attached to us and pass those csv through a flow that I have already created.
I have managed to create a program that treats the csv as I want and the delimiter that I want, the problem is that when it comes to automating the download of files from Outlook it does not work.
What I have done is create a rule with the following VB code that I found on the internet:
Public Sub SaveAttachmentsToDisk(MItem As Outlook.MailItem)
Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
sSaveFolder = "C:\Users\ES010246\Desktop"
For Each oAttachment In MItem.Attachments
oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
Next
End Sub
I have changed the path to my personal path where i want the files are downloaded.
website: https://es.extendoffice.com/documents/outlook/3747-outlook
The problem is that this code does not work for me, it does absolutely nothing for me and no matter how much I search the internet, only this code appears.
Is there any other way to do with SAS what I want? What is it to automatically download 8 csv files sent to me by Outlook, or has someone experienced the same thing as me with VBA?
I have followed all the steps about 7 times so I think the error is not in copying the code or selecting certain options wrong, in fact I had copied and pasted the code and later I modified the path where I wanted those to be saved. files but it doesn't work, does anyone know why?
I will be tremendously grateful, thank you very much for everything!
First of all, you need to make sure the file name and path doesn't include forbidden symbols.
The VBA macro used for a rule in Outlook is absolutely valid except that a mail item may contain the attached files with the same name, so a file saved to the disk may be overwritten (saved with the same name). That's why I'd suggest generating a file name with your own unique IDs making sure that DisplayName property is not empty and has a valid name what can be used for file names (exclude forbidden symbols).
Also you may consider handling the NewMailEx event of the Application class which is fired when a new message arrives in the Inbox and before client rule processing occurs. Use the Entry ID returned in the EntryIDCollection string to call the NameSpace.GetItemFromID method and process the item. This event fires once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem, MeetingItem, or SharingItem.
The Items.ItemAdd event can be helpful when items are moved to a folder (from Inbox). This event does not run when a large number of items are added to the folder at once.

Is it possible to get shell properties for an item not in the shell namespace?

Short Version
How does the shell get the properties of a file?
Long Version
The Windows Shell exposes a rich system of properties about items (e.g. files and folders) in the shell namespace.
For example:
System.Title: A Quick Guide for SQL Server Native Client OLE DB to ODBC Conversion
System.Author: George Yan (KW)
System.Document.LastAuthor: rohanl
System.Comment: To learn more about this speaker, find other TEDTalks, and subscribe to this Podcast series, visit www.TED.com Feedback: tedtalks#ted.com
System.ItemParticipants: George Yan (KW)
System.Company: Contoso
System.Language: English (United States)
System.Document.DateCreated: 6/‎10/‎2014 ‏‎5∶16∶30 ᴘᴍ
System.Image.HorizontalSize: 1845 pixels
System.Image.VerticalSize: 4695 pixels
System.Image.HorizontalResolution: 71 dpi
System.Image.VerticalResolution: 71 dpi
In order for the shell to read these properties, it obviously has to use a lot of sources:
Windows Media Foundation IMFMetadata works great for images and movies
Windows Imaging Component (WIC) probably has a lot of APIs for reading metadata
I'm not sure if IFilter can retrieve Title, Author, Subject, Comments etc from Office documents
Either way, it has to read the file contents stream and do something with the contents of the file in order to get all these fancy shell properties. In other words:
IStream \
+ |--> [magic] --> IPropertyStore
.ext /
Can use it with my own stream?
I have items that are not in the shell namespace; they are in a data store. I do expose them to the shell through IDataObject as CF_FILEDESCRIPTOR with an IStream when its time to perform copy-paste or drag-drop. But outside of that they are just streamable blobs in a data store.
I'd like to be able to leverage all the existing work done by the very talented and hard-working1 shell team to read metadata from a "file", which in the end only exists as an IStream.
Is there perhaps a binding context option that lets me get a property store based on an IDataObject rather than a IShellItem2?
So rather than:
IPropertyStore ps = shellItem2.GetPropertyStore();
is there a:
IPropertyStore ps = GetShellPropertiesFromFileStream(stream);
?
How does the shell get all the properties of a file?
Bonus Chatter - IPropertyStoreFactory
This interface is typically obtained through IShellFolder::BindToObject or IShellItem::BindToHandler. It is useful for data source implementers who want to avoid the additional overhead of creating a property store through IShellItem2::GetPropertyStore. However, IShellItem2::GetPropertyStore is the recommended method to obtain a property store unless you are implementing a data source through a Shell folder extension.
Tried
IPropertyStore ps = CoCreateInstance(CLSID_PropertyStore);
IInitializeWithStream iws = ps.QueryInterface(IID_IInitializeWithStream);
But CLSID_PropertyStore does not support IInitializeWithStream.
Bonus Reading
MSDN: Initializing Property Handlers
Property handlers are a crucial part of the property system. They are invoked in-process by the indexer to read and index property values, and are also invoked by Windows Explorer in-process to read and write property values directly in the files.
MSDN: Registering and Distributing Property Handlers (spellunking the registry for fun and reading contracts from the other side)
(Have some experience in Property Store handlers) How I see a solution:
Get PropertyStore handler CLSID for your file extension. You should use 2 regkeys key:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\PropertySystem\PropertyHandlers\.yourext
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\PropertySystem\SystemPropertyHandlers
Create two objects with CoCreateInstance
If you have 2 object you can combine them into single object with PSCreateMultiplexPropertyStore
Query for IInitializeWithStream (also you can try to query IPersistStream).
If the PropertyStore object supports IInitializeWithStream/IPersistStream: you are lucky - just init your object and query the properties you need. If does not - you still have (dirty) variant to create temporary file and then use IPersistFile.

How to show to the user that a file is attached to an element

We are currently using a stereotype with an attached shape script to show that files are linked to an element
However, going this route means that our users cannot use another stereotype, or it will overwrite (Even if multiple stereotypes can be applied, only one will be shown and only one shape script will be applied)
I tried using the "A" icon for when a linked document has been created for an element by modifying the style property of the element, but setting MDoc=1 without a linked document will not show the icon.
What would be an effective way of showing there are files linked to a document without using stereotypes(if any)?
You are out of luck here. The Link to Element Feature on Notes works for many things, but not for the related files.
In case you could link <<files>> stereotyped Notes to the elements and run a batch script that looks into the Related/Files and fills them in the Notes. Basically that would be something like:
for dia in all diagrams:
for diaobj in dia.diagramobjects:
obj = rep.GetElementByID(diaObj.ElementID)
if obj.Type == "Note" and obj.Stereotype == "files":
con = obj.connectors.getAt(0) # assume there's only one connected
ident = con.clientId
if ident == obj.ElementId: ident = obj.sourceId
fObj = rep.GetElementByID(ident) # element connected to the note
# parse fObj's files and write them as string to obj's Note attribute

Where do Progress / QAD "TMPxxxx" numbers come from?

We have several processes which generate temporary references in the form
"TMPxxxx" where x is a digit. These appear to be used for session
temporary file names, and for keys in the usrw_wkfl table. I¹m not sure if
these are generated by QAD (MFG/Pro), or Progress, or just by the individual
programs.
A colleague has suggested they come from Progress/Openedge, but I can't find
anything in the documentation, or any references on the web either for QAD
or Progress, hence this question.
If there is a standard process within Progress/Openedge or QAD for this ­could
somebody point me in the right direction please?
Thanks!
TMPxxxx session id is created by QAD(MFG/PRO) an ERP application.
There is an Security control menu item (mostly menu number: 36.3.24) in MFG/PRO (QAD) and field that name is "Session ID Prefix".
It's used for temporary system-generated work file (creation when login, deletion when logout). Exp: qad_wkfl, sr_wkfl and some file creation in temp directory.
You can monitor users who get TMP id for which session.
for each mon_mstr no-lock:
display
mon_userid column-label "Mfg/Pro User ID"
mon_program column-label "Mfg/Pro Program Name"
mon_sid column-label "Mfg/Pro Temp Session Id"
mon__qadi01 column-label "Progress Session Id".
end.
Maybe too late but I hope this will help you
OpenEdge creates various temporary files while the session is active. Each file has a 3-character prefix followed by a random number. The different prefixes are:
dbi: Stores temporary tables
lbi: Local before-image file (subtransaction undo)
ped: Edit buffer contents
rcd: Cache of r-code being run in a session
srt: Temporary sort space; session compile storage
trp: Stores Data Dictionary changes until they are saved
Sometimes the random number is the process ID of the Progress session, but not always. The location of these files can be controlled with the -T startup parameter.
Here is a Progress knowledge base article about the temp files:
http://knowledgebase.progress.com/articles/Article/P111424
Here is the Progress online documentation:
https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dpabl/temporary-file-i-2fo.html

Zend Lucene with symfony and i18n

I've went through the Jobeet Tutorial for integrating Zend Lucene into a symfony (1.4.8) project in order to add search capabilities into my frontend of my site (through indexing). Among others, the key concept is to use updateLuceneIndex during model's save action (needs to be overridden) in order to create/update the index of the specific entry.
My model has i18n fields, some of which (i,e name, title) I want to be inserted in the index. Everything works as expected but when it comes to save the i18n fields into the index all I get is blank values ($this->getName() returns empty string). I'm inspecting the created index with the Luke.
I ended up that this has nothing to do with the Zend Lucene but with symfony. It seems that during save the information for i18n fields isn't available (or is it?). I've also tried hook up the update during preSave(), postSave() but no avail.
So I want to ask how am I supposed to get my model's i18n field values during the save action in order to update the index accordingly?
Important note: This happens only during doctrine:data-load task. If I manually insert or update a record the index gets updated accordingly.
One last related question. It would be nice if I could save different keywords for each of the languages of the field of the model. How can I get the different values for each field's language inside the model?
The reason of this strange behaviour of Symfony is that when you are loading fixtures via cli, it has no context loaded (for instance when you try to get context instance sfContext::getInstance(), youll get "context instance does not exists" error exception).
With no context instance available, there is no "current culture" and with no current culture, there is no value of i18n fields.
The symfony context actualy supports all I18N functionalities with current User culture ($currentUserCulture = sfContext::getInstance()->getUser->getCulture()).
This all means 2 things:
You cant use symfony "current user culture" capabilities while you are
in cli session
If you needs to have sfContext::getInstance() somewhere in your
code (especialy in the models), you have to close it into condition to avoid any troubles with unexpected and hard to find exceptions while in cli
Example of getting current culture in model class (it will not pass condition while in cli):
if (sfContext::hasInstance()) {
sfContext::getInstance()->getUser()->getCulture();
}
So when you cant use Symfony i18n shortcuts (like $record->getName()), you have to work around it.
In Your symfony1-doctrine models you always have $this->Translation object available.
So you can access your translation values object via something like $this->Translation[$culture].
Its up to you to work with that, you can use your default culture $this->Translation[sfConfig::get('sf_default_culture')], or interate trough all your supported cultures from some global configuration (i recommends you to set it in one of your configuration files globaly accross of all apps - maybe /config/app.yml).
Example of getting $record Translation object in any situations:
if (sfContext::hasInstance()) {
$translation = $this->Translation[sfContext::getInstance()->getUser()->getCulture()];
}
else {
$translation = $this->Translation->getFirst();
// or: $translation = $this->Translation[$yourPreferedCulture];
}
// you can access to modified fields of translation object
$translationModified = $translation->getModified();