In this post under Java LDAP, I will show with example how to modify an existing attribute of an ldap entry. For our example I will modify the “description” attribute of an ldap entry identified by dn. I will show two approaches through which we can modify the attribute of an ldap entry. Below is…… Continue reading Modifying an existing attribute of a ldap entry
Tag: Java
Deleting an LDAP entry
In this post under Java LDAP, I will explain how to delete an LDAP entry. The below figure shows the LDAP DIT (Directory Information Tree) I will show two approaches to delete an ldap entry or sub context. In the first approach we will delete the ldap entry with dn “cn=user3,ou=dev,dc=example,dc=org”. In the second approach…… Continue reading Deleting an LDAP entry
Creating a new entry in ldap
In this post under Java LDAP, I will show how to create a sub context with an example In LDAP, sub context means a new LDAP entry under another existing LDAP entry or context. Below is the screenshot of LDAP DIT (Directory Information Tree) I will show two approaches that can be used to create…… Continue reading Creating a new entry in ldap
Retrieving attribute of an ldap entry
In this post under Java LDAP, I will show with example how to retrieve an attribute of an existing ldap entry. For our example we will take the below ldap entry. Please note in the above screenshot, all the attributes have only one value except attribute “telephoneNumber” which has 2 values. Below is the complete…… Continue reading Retrieving attribute of an ldap entry
InitialDirContext lookup method
In this post under Java LDAP, I will show how to lookup for an entry in LDAP directory tree using ldap distinguished name. Below is the complete main class for your reference Main class 1 package package2; 2 3 import java.util.Hashtable; 4 5 import javax.naming.Context; 6 import javax.naming.NamingException; 7 import javax.naming.directory.DirContext; 8 import javax.naming.directory.InitialDirContext; 9…… Continue reading InitialDirContext lookup method
Connecting to LDAP server
In this post under Java LDAP, I will explain how to connect to LDAP server with an example. Below is the complete code Main Code 1 import java.util.Hashtable; 2 3 import javax.naming.Context; 4 import javax.naming.NamingException; 5 import javax.naming.directory.DirContext; 6 import javax.naming.directory.InitialDirContext; 7 8 public class LDAPDemo1 { 9 public static void main(String[] args) { 10…… Continue reading Connecting to LDAP server
Adding and accessing static members to Java Record
In this post under Java, I will show with example how to add and access static members in Java Record. Below is the structure of “Student” Record with static members Student 1 package core.record;2 3 public record Student(int id, String name, int age) {4 public static int noOfStudents;5 public static void display() {6 System.out.println(“Number of…… Continue reading Adding and accessing static members to Java Record
Simple Java Record Example
In this post under Java, I will introduce you with example to Java’s Record classes. Introduced in Java 16, is a immutable data class, whose main purpose is hold read only data. Below shows how to create Record class. Person Record package core.record;public record Person(int id, String name, int age) {} We save the file…… Continue reading Simple Java Record Example
Merging two character arrays
In this post under Java. I will show with example how to merge two character arrays into one. Below is the complete code for your reference. Main Class 1 package core.string; 2 3 public class Example1 { 4 public static void main(String[] args) { 5 char[] inputArray1 = {‘a’, ‘b’, ‘c’}; 6 char[] inputArray2 =…… Continue reading Merging two character arrays
Merging text files
In this post under Java I will with example how to merge two or more text files. Below is the complete code for your reference Main class 1 package io;2 3 import java.io.*;4 5 public class IOExample3 {6 private static int BYTES_TO_BE_READ = 1000;7 private char buffer[] = new char[BYTES_TO_BE_READ];8 9 public static void main(String[]…… Continue reading Merging text files