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;
}

}
}



Aloaha Software / Knowledge Base / PDF SDK / PDF Encryption API / LDAP encryption Sample
create PDF Software

LDAP encryption Sample

Any questions?
Aloaha Software - PDF Encryption API / LDAP encryption Sample / Certificate Encryption
ProductsKnowledge BaseShopSupportPress
Deutsche VersionEnglish version