Tag Archives: code

Simple Java AD/LDAP Authenticaion Code


There are so much of code and reference available for AD/LDAP integration in Java. I also searched a lot and the below code worked for me.
As a non-java developer I found so interesting while working on some complex java stuff.

 

import java.util.*;
import javax.naming.*;
import javax.naming.directory.*;
public class ADTestNew {
    public static void main(String[] args) {
    try {
        Hashtable env = new Hashtable();

        env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");

        env.put(Context.PROVIDER_URL,"ldap://192.168.100.225:389"); //replace with your server URL/IP

        // This line is optional based on environment. You can try with comment or without comment also.
        env.put(Context.SECURITY_AUTHENTICATION,"DIGEST-MD5"); //No other SALS worked with me

        env.put(Context.SECURITY_PRINCIPAL,"login"); // the user name.

        env.put(Context.SECURITY_CREDENTIALS, "Passw0rD"); //the password.

        DirContext ctx = new InitialDirContext(env);

        ctx.close();

    } catch(NamingException ne) {
        System.out.println("Error authenticating user:");
        System.out.println(ne.getMessage());
        return;
    }
    //if no exception, the user is already authenticated.
    System.out.println("OK, successfully authenticating user");
    }
}

Happy Java.

Groovy: Use findAll to fetch string from long string.


How to use findAll() in groovy, when you have to find some specific string from string.

def name= 'this#   is to%% te$st ^in*d~~ all $$from CCa s<>>ng, this is basi?><:"{}cally fetch only interested thing.'
def name1 = ''
def findName = name.findAll(/[A-Za-z\s+]/).each{name1 += "${it}"}
println findName
println name1

We can also use

def findName = name.findAll(/[A-Za-z\s+]/)
def name1 = findName.join('')

This code will fetch only sting and space and give output in name1.

Output –

run-single:
[t, h, i, s,  ,  ,  , i, s,  , t, o,  , t, e, s, t,  , i, n, d,  , a, l, l,  , f, r, o, m,  , C, C, a,  , s, t, i, n, g,  , t, h, i, s,  , i, s,  , b, a, s, i, c, a, l, l, y,  , f, e, t, c, h,  , o, n, l, y,  , i, n, t, e, r, e, s, t, e, d,  , t, h, i, n, g]
this   is to test ind all from CCa sting this is basically fetch only interested thing
BUILD SUCCESSFUL (total time: 1 second)

Program has many ways to do.
Happy Programming.

MoneyBookers Dummy Credit-Card Numbers for testing


MoneyBookers Dummy Credit-Card Numbers. I used this for testing. I hope this will be helpfull for you also.

VISA: 4000001234567890
AMEX: 371234500012340
MASTERCARD: 5232000000123456
DINERS: 36123456789000
LASER: 5612345678900001
MAESTRO: 51234567912345670
SOLO: 631234567891234560
JCB: 3555123456789120
CARTBLEUE: 5817840047112340

** NOTE – Not sure for current status, I am NOT sure that is this still available as dummy-numbers or NOT. Use this with your concern.

WWW-Web Site Essentials


I was reading a book couple of months back.

That book contains what are the fields you require for a good website. I noted down the points.

  • Testimonials
  • Promotions/offers
  • Photo Gallery
  • Blog
  • A good domain name
  • A good hosting company
  • CMS
  • Content update facility
  • Social media integration
  • RSS
  • Newsletter
  • Sitemap
  • About Us Page
  • Contact Us Page
  • Location Page
  • Client List / Affiliate List
  • Site Backup Facility
  • Site Analytics
  • Email Processes
  • Press Releases
  • Download
  • Search site
  • Notifications.
  • Security

Huff!! That contain so many things. This is not all.

If a site has all these things then this is complete site for ready for users.
Then it depends that what are the target users and who will use the site.
Based on that dynamic content can be added into the site.

Happy Web.

bole to me mumbai coder – “मी मुंबई coder”


New to mumbai, but language is super cool here.

Even I have observed that I am using some of the phrases for my/our daily use.

  • यार लग रहा है loop मैं कुछ लोचा है …
  • सुन ना, तेरा हुआ क्या …
  • ज्यादा लोड मत ले, ये code तो automatic चलेगा …
  • यार, क्या deadline दिया है, मेरी तो फट रही है.
  • अरे! क्या ज़क्कास code लिखा है तुने
  • आईला !! क्या बात कर रहा है , सच मैं….
  • हट साले ! एक दम अतरंगी है …
  • And many more…

    बोले तो, अपुन का एकदम मस्त चल-रेला है. तू बोल न तेरा कैसा चल रहा है…

    what is your Blogger Code


    I just got my blogger code like this …
    what is your blogger code.

    B7 D- T- K- S+ F- I- O++ X- E+ L– C– Y4 R- W- P++ M2 N- H–

    Find last day of the month in PHP


    Yday I was working with dates and got the situation to get the last day of the month so got this piece of code.

    date(’Y-m-d’,strtotime(’-1 second’,strtotime(’+1 month’,strtotime(date(’m').’/01/’.date(’Y').’ 00:00:00′))));
    

    And this piece of code will gv you the last day of the your corrent month. 

    tags: , , ,