c# LDAP encryption sample

'The code sample below was created by
'Pedro Leal of aviita solutions
'www.aviita.li

using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Reflection;

namespace encrypt
{
public class PDFEncrypter
{
public byte[] encryptPDF(byte[] sourcePDF, string encryptuser)
{
string ldap = ConfigurationManager.AppSettings["ldapconnectin"];
string eku = ConfigurationManager.AppSettings["enhancedkeyusage"];
byte[] outputPDF = null;
int ku = 0;
bool noOverwrite = false;

//argument array
object[] objarray = new object[7];
objarray[0] = ldap;
objarray[1] = sourcePDF;
objarray[2] = outputPDF;
objarray[3] = encryptuser;
objarray[4] = ku;
objarray[5] = eku;
objarray[6] = noOverwrite;

//modifiers- very importend
ParameterModifier p = new ParameterModifier(7);
p[0] = false;
p[1] = false;
p[2] = true; //without this, null will return!
p[3] = false;
p[4] = false;
p[5] = false;
p[6] = false;
ParameterModifier[] mods = { p };


Type aloahapdf = Type.GetTypeFromProgID("aloahapdf.edit");
object aloahapdfLateBound = Activator.CreateInstance(aloahapdf);

string msg = (string)aloahapdf.InvokeMember("encrypt_pdf_by_LDAP_BA"
, System.Reflection.BindingFlags.Default | System.Reflection.BindingFlags.InvokeMethod
, null
, aloahapdfLateBound
, objarray
, mods
, null
, null);

outputPDF = (byte[])objarray[2];

return outputPDF;
}

}
}



Please ask...

Although we really tried hard, there are always questions left open.

Please send us your question.
We would be glad to answer it.
PDF SDKPDF Signature APICertificate PropertiesSample CodeText StampsPDF AttachmentsImage 2 PDFPDF to Multipage TIFFAppend PDFInsert Blank PageRender ImageStamp PDF with PDFDraw PDF as LetterheadApply LetterheadPDF BackgroundsAdd NotesURL HotspotSecure PDF ViewerPDF OptimizerPDF Encryption APIc# crypto sample40/128 Bit encryptionLDAP/Active Directory EncryptionLDAP encryption SamplePDF Printing APIPDF BookmarksPDF BarcodingMerge PDF DocumentsSample APIsResize PDFCrop PDF PagePDF InformationPDF2TXTNormalize PagesDirect PDF ConversionPDF Form Saver SDKSmart Card APIAloaha Web ServicesAloaha Print MonitorAloaha Remote ConfigurationWebDAVLDAP ClientProgramming Office MacrosIIS Event Sinks