How can I authenticate a User In Windows Active Directory?

I need to authenticate a user in Windows Active Directory, but I found use the code below will return true if the user name and password are both correct and false if one of them is wrong. But when I input a user name which is not exist in Active Driectory with a blank password, it will also return true. What shall I do? Ask every user must input a password withnot blank?
Please give me some help to solve this problem. Thanks a lot.
Code:
private Context ctx = null;
Hashtable env = new Hashtable ();
boolean isValid = false;
try {
this.setEnvironmentProperties();
String domainName = AuthenticateResources.getString("mydomain.com");
//set the name of domain with the user name
String fullName = name + "@" + domainName;
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL,"ldap://mydomain:389");
env.put(Context.SECURITY_AUTHENTICATION,"simple");
//set user related information
env.put(Context.SECURITY_PRINCIPAL, fullName);
//set user password
env.put(Context.SECURITY_CREDENTIALS, password);
//validate user
ctx = new InitialDirContext(env);
isValid = true;
}catch (AuthenticationException ex){
isValid = false;
catch (NamingException ex) {
throw ex;
}finally{
this.freeContext();
return isValid;

This is usually a problem if Anonymous Binding is enabled. I have faced this in other Directory Servers, but I am not familiar with Active Directory.
I think by default Active Directory disables Anonymous Binding, but you may want to check.

Similar Messages

  • How can I capture delete user event in Active Directory 2008 using Powershell command

    Hi,
    In my Active Directory every user have own home drive in the file server. When I delete user I also need to delete folder from the server. 
    My target is make the process automated, so that when I delete user account form AD, the folder associate with user also delete.
    Can I write any power shell script to grep the delete event  and remove folder from file server.
    Thanks
    Tamim Khan

    You can setup event viewer to provide alerts (email alerts) for event id 630.
    Find an existing Event ID 630 entry, right click on it and "Attach Task To This Event...."
    Follow the wizard.
    ** Event ID Sample **
    Event ID: 630
    Type: Success Audit
    Description: User Account Deleted:
    Target Account Name: %1 Target Domain: %2
    Target Account ID: %3 Caller User Name: %4
    Caller Domain: %5 Caller Logon ID: %6
    Privileges: %7
    - Chris Ream -
    **Remember, if you find a post that is helpful, or is the answer, please mark it appropriately.**

  • How to Re-Authenticate an user to an active session

    Hi frns,
    Following is my existing flow.
    Initially the user logs in with valid usename and password. He will do some transactions in the application. Meanwhile if he is idle for more than 15 minutes, the current session will be lost and then if he wants to continue with the application he will be forcefully sent to the login page to get authenticated once again.Now we have to start the transaction freshly.
    Following is my new requirement.
    While doing some transaction,If the user is idle for more than 15 mins,one authentication jsp page should be displayed on the current screen asking the user to enter usename and password once aagain. If the authentication is succeeded then he should get back to the same screen previously he is doing transaction and allow the user to continue the transaction.
    Here two scenarios should be considered.
    1) The Re-Authentication screen should be displayed on the top of the screen in which he is idle for more than 15 mins.
    2) If the Re-Authentication succeeds, then user should be allowed to continue the transaction in which he is idle previously.
    Please help me in this regard. Very urgent...
    Thanks,
    Srinivas.

    The idea is to seperate the session management from the security management.
    We want the user's sessions to last for a long time but there still needs to be an upward limit. So a good limit is four hours. This allows a user to go to a meeting or to lunch and then return and pick up where he left off. So we set the session time on on the server to four hours.
    However if there is fifteen minutes of inactivity we want the user to re-authenticate himself. So if the user goes to lunch we don't want some one to be able to access his session. This is different from expiring the session. We don't expire the sesion but we expire the user access to the session.
    So we create a security module that handles all user authentication. We creat this module as a Servlet Filter so that all requests have to pass through the module. On initial request we redirect the user to a log in page where he provides his username and password. On authenitcation we create a user object that we store in the session. We also store the date/time that the request was made in a hashmap using the session or session id as the key.
    On subsequent requets we can chedk for the existance of this object to see if the user has been authentcated. If the user object exists we retrieve the date/time of the last request and check to see if fifteen minutes has expire between requests. If the time difference is less than fifteen minutes we store the new time in the hasmap. if the time difference is greater that fifteen minutes we redirect the user to a log in page.
    There are certain mantainance actions that wlll need to be done:
    1: Removing expired session entries from the hashmap using HttpSessionListener.
    2: Differenciating a normal request from a re-authorization request
    3: Forwarding the user to request resource after re-authorization

  • How Can I change all User Passwords Within a Directory Instance

    Hi Experts,
    I've been asked to refresh an old directory instance with some production data.  Easy enough I thought, however, the user has requested that all user passwords within the old directory instance are preserved.  Is that at all possible?  My chain of thought was that I can extract user passwords from the old instance into a file: -
    # ldapsearch -D cn="Directory Manager" -w xxxxxxxx -b o=xxxxxxx objectclass=* userpassword > <name of file>
    And then then use ldapmodify (or alike) to re-import the user passwords once I've refresh the old instance with the production data.  However, to my knowledge, in order to modify a particular entry via a file, i'd need the following format: -
    dn: gci=-1,ou=people,o=xxxxxxxx
    changetype: modify
    replace: userpassword
    userpassword: xxxxxxxxxxxxxxxx
    The only information I have in the file I created using the ldapsearch command above is as follows: -
    dn: gci=-1,ou=people,o=xxxxxxxx
    userpassword: xxxxxxxxxxxxxxxx
    I don't want to have to edit the file and add the relevant missing entries accordingly as the generated file has somewhere in the region of 150 thousand entries.
    Am I approaching this the correct way?  Is there any other mean of achieving my requirement.
    Thanks in Advance.

    Hi,
    It does not seem a big deal to add the missing lines to your output file.
    For instance, the following awk command should do the trick
    cat search.out
    dn: gci=-1,ou=people,o=xxxxxxxx
    userpassword: xxxxxxxxxxxxxxxx
    cat search.out | awk '/userpassword/ {print "changetype: modify} ; print "replace: userpassword"; }  {print $0}
    dn: gci=-1,ou=people,o=xxxxxxxx
    changetype: modify
    replace: userpassword
    userpassword: xxxxxxxxxxxxxxxx
    Then you can use ldapmodify to apply your changes
    -Sylvain

  • I'm using "window.open()" to show one Calendar in a popup window. I can see that the popup is re-sizable. How can I prevent the user from re-sizing the popup?

    I'm using "window.open()" to show one Calendar in a popup window. I can see that the popup is re-sizable. How can I prevent the user from re-sizing the popup? I have tried "resizable=yes|no|1|0" and that seems to be not working.

    You can't prevent users from resizing a pop-up.
    *https://developer.mozilla.org/en-US/docs/Web/API/window.open

  • How can I authenticate and authorize with Web Service on ESB ?

    Hello,
    I want to authenticate and authorize client with Web Service published
    by HTTP/SOAP BC.
    Simply if it is an Web Service as J2EE application, I will use
    Basic Authentication with JAX-RPC and Realm.
    But I think that Web Service published by HTTP/SOAP BC is not belong
    to J2EE Application. Threre is no place to describe security role mapping
    (like web.xml).
    JBI 1.0 the section "5.5.1.1.3 Normalized Message Properties" comments
    JAAS Subject is given in the NM Properties. Really in this package
    com.sun.jbi.internal.security.*
    implements JAAS autentication and authorization (at JaasAuthenticator).
    But I can't see how to configure my Service to use this.
    How can I authenticate and authorize with Web Service on ESB ?
    I referred to the resources.
    Mutual Authentication for Web Services: A Live Example
    http://developers.sun.com/prodtech/appserver/reference/techart/mutual_auth.html
    XML and Web Services Security
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Security7.html
    JAAS Authentication Tutorial
    http://java.sun.com/j2se/1.4.2/docs/guide/security/jaas/tutorials/GeneralAcnOnly.html
    Thanks,
    Takurou
    - environment ---------------------------------------------
    OpenESB : Project Open ESB Starter Kit
    AppServer : Sun Java Systems Application Server 9.0 PE
    OS : Windows XP
    I don't assume to use SSL (if It's necessary I will try).
    User information is stored in a LDAP Server.
    -----------------------------------------------------------

    Hello,
    I read this resource.
    SecurityDesign
    http://www.glassfishwiki.org/jbiwiki/Wiki.jsp?page=SecurityDesign
    Then I think [non-ssl and ssl/tls and so on] securing by basic authentication is ongoing feature at this time.
    But I can't see well why this page comments 'HTTP over SSL, TLS'.
    HTTP/SOAP Binding Component Overview
    http://download.java.net/general/open-esb/docs/jbi-components/httpsoap-bc.html
    Does BC support only "SSL server authentication" ?
    Doesn't BC support "SSL client authentication" by username/password ?
    Thanks,
    Takurou

  • How can I develop co-broswing on Windows platform with java language?

    How can I develop co-broswing on Windows platform with java language?
    The function will be realized
    Now I want to develop a co-broswing system with java language on Windows platform.That is to say I will develop
    a application run on client to track the present browser.Wheh the URL address of your present if changed(for example
    when you click a link or submit a form),the application will capture the new URL address and send it to the other
    client that make co-browsing connect with you.The browser on the other client side will catch the new URL and refesh
    the page to show the page.
    The question I fall across and want to ask you
    (1)How to watch system process with java on the Windows platform?Because I want to get the process information of
    the present broswer,and then get the URL address of the present broswer.
    (2)Develop an application to watch the URL address of the present broswer continuance,If the URL address is changed,
    then send the new URL address to the client on the other side,let his broswer to show the new page using the new URL.

    Paulc, A proxy server is not the right thing.
    What our man here is looking for is a solution for two
    users to kind of surf the net "in tandem" - when one
    user navigates to a different web page, so does the
    other user,
    These are typically used in call center applications
    where the advisor guides a caller through , say
    filling in an insurance form or pointing him to the
    right product specification pages.
    Xing, why are you using Java for this ? You need
    something that has better windows integration. If you
    look on MSDN.microsoft.com and search for "explorer
    bar" you will find solutions to the questions that you
    raised.
    There are also commercial products on the market that
    already do this kind of stuff. there is one from
    www.genesyslabs.com which is considered to be the best
    of breed.
    It is difficult or almost impossible to do this in
    Java for a commercial application.
    If you are developing this as an academic exercise,
    give it a try. Post your email address here, and I
    will contact and help you out if you like.my e-mail is below ,I want to contact you and need all of your help.
    [email protected]

  • How can i attach a user-speci​fied header to each UDP packet?

    Hello,
    i have here a question about UDP:
    i want to stream live-videos using UDP. To avoid/observe some possible problems that could occur (e.g. wrong packet-order, packet loss etc.) i am planning to add a header to each UDP packet with e.g. frame-nr. , frame-size, packet-nr...
    Question:
    1. (How) Can i control the UDP packet size in LabVIEW?
    2. If possible, how can i add a user specified header to each/certain (e.g. the first or the last packet of the frame) packet?
    Thanks!
    WLAN
    Message Edited by wlan on 01-26-2007 03:02 AM

    WLAN,
    i just copied the help regarding the max size-terminal from the LV-help:
    "max size is the maximum number of bytes to read. The default is 548. Windows If you wire a value other than 548 to this input, Windows might return an error because the function cannot read fewer bytes than are in a packet"
    So, please do not change this value....
    UDP creates packets from the data you transmitt. Each packet in Windows should have a size of 548 bytes or less. So this should read one whole packet at a time.... Decreasing this could lead to problems if the packet is larger.... Increasing this value changes nothing since the packets themselfs do not get larger only by trying to read more bytes..... Since you cannot alter the packetsize from LV, you shouldnt bother about that anymore.
    And to add (again): UDP does not garantuee ANY correct transission. So you will never get any note if the first packet of a frame was lost. If you need some kind of garantuee for this, you have to use TCP (btw. infact, the TCP header uses 192 bytes, containing the infos like seen in the attached gif).
    regards,
    NorbertMessage Edited by Norbert B on 01-31-2007 11:12 AM
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.
    Attachments:
    tcp_header.gif ‏9 KB

  • How can i change the user on FaceTime? im trying to do this on a iMac

    how can i change the user on FaceTime? im trying to do this on a iMac

    I'm using an iMac with OSX 10.6.8.  The proceedure on your system is probably similar.
    Get the Facetime window up, and go to Facetime preferences.  Click on "account,"  you'll see a view account option that will prompt you to sign in with your Apple id and password.  From there you can make the changes that you want.

  • How can I have multiple users on iTunes (in order to connect to a shared office iPad)?

    How can I have multiple users on iTunes (in order to connect to a shared office iPad)? Currently each of us has our own iTunes account, so I've made an "all office" Apple ID. However, I can't seem to get two different accounts (my personal and the office) to work on my machine. Even when I login as "the office", my personal library is still showing. Additionally, when I try to setup with a first-time use in iTunes, I get an error that I don't meet the minimum age requirement - no matter what birthdate I enter!

    The library exists regardless of which user is logged in.
    The only way around that is to create different user accounts on the computer.
    There is no way to have 20 unique iTunes users access a shared iTunes under a single login on the computer.

  • How can I have multiple users on one apple id?

    How can I have multiple users on one apple ID?
    ie: I have my apple ID with my own credit, how can I set up credit for my son under the same apple ID, so that he can still access the same apps I've already downloaded and paid for?

    I've been trying to figure out a clean way to do this too. I think you may need more than one Apple ID – one that is shared and used to purchase "sharable" items and then "individual" Apple IDs for you and your son. That's the idea that I'm pursuing for the moment.
    It seems that there must be a way to do this, App Store purchases for the Mac are licensed across multiple machines. iPhone app purchases have "all your devices" licensing. Makes me think that Apple has a process in mind for sharing an account (or associating a device with multiple accounts).
    Other things I've learned:
    - Apparently you can't merge Apple ID accounts. I asked about this once at an Apple Store and was told that there was no way to do it.
    - If you share an Apple ID the Messages app behaves in a somewhat surprising manner. It must use your Apple ID to decide where messages should be sent because all users get all messages. This can make it very hard to organize a surprise party :-)

  • How can I allow other users on my macbook to view my iphoto library when th

    How can I allow other users on my macbook to view my iphoto library when they are logged in. I do not have a network, and the users (my family) all log in seperately when they use the computer. Does anyone know? Thank you.

    rdoss
    Welcome to the Apple Discussions.
    If you want others to be able to see the pics, but not add to, change or alter your library, then enable Sharing in your iPhoto (Preferences -> Sharing), leave iPhoto running and use Fast User Switching to open the other account(s). In the other account(s), enable 'Look For Shared Libraries'. Your Library will appear in their source pane.
    Remember iPhoto must be running in both accounts for this to work.
    Regards
    TD

  • I bought 26 new songs under my work e-mail and now i can't copy them to my i-pod because it has another music library on it. How can i combine both user id's to the same purchased account

    I have 2 user id's with apple, i bought 26 songs from my laptop recently using my work e-mail. I plug my i-pod to sync it and it says that my i-pod is tuned with another library. i don't want to erase the songs I have already because they are about 760 and the new ones are 26 only. how can I combine both user id's and consolidate all the music into one user id?
    everytime i try to do something it asks me to reset the password. I have done it already 6 times.
    there is no phone # to call.
    Thanks
    Elena

    Alright, please follow these steps in order to get it working properly again.
    Please change your Apple ID back to your old email address (that you used as Apple ID before) here: http://appleid.apple.com
    Then go to all your devices - iPhones, iPads, Mac etc. - ("Settings > iCloud") and delete your iCloud account from this devices (+ turn off Find My iPhone, but I guess it will ask you that anyway)
    After that go back to http://appleid.apple.com sign in again, and now change your Apple ID again to your new email address.
    Finally, set up your iCloud account on all your devices again.
    Now, everything should working properly again.

  • HT201342 How can I change the USER of my i-cloud address? My 12 year old set up the e-mail account and used a silly user name (like: turtle!!). I would like to have an icloud e-mail account but under my own user name. The other /old name can be deleted?

    How can I change the USER name of my i-cloud e-mail account? It was set up by my son and he used a silly / embarrassing user name. I would like to change this name OR set up another i-cloud e-mail account under my own name / reference. Help?

    iCloud email addresses can't be changed or deleted, but you can set up an alias namethat he can use which will be linked to his current iCloud account and will receive email in the existing iCould inbox.  This guide explains how: http://support.apple.com/kb/PH2622.

  • How can I transfer two user names from an iMac to a new macbook?

    How can I transfer two user names from an iMac to a new macbook?
    got a new laptop and need to transfer two usernames to it, complete with all documents help?

    Assuming you haven't already set up a user, the easiest way is to use the Setup Assistant during first boot of the new Mac, with the two Macs connected by firewire.
    You'll be prompted to migrate from a choice of sources - choose "from another Mac", select the catagories of data you want to transfer and follow the instructions.
    More info here, in Pondini's FAQ; http://pondini.org/OSX/SetupAsst.html

Maybe you are looking for