Read this to find out how to add/update/delete users and change/reset passwords programmatically

WebLogic 7.0
I have read a number of questions on how to do these but not many answers, so
after figuring it all out, I thought I would post a message describing all these
tasts (It would be great if BEA would start something like 'HOW-TOs for Linux'
for WebLogic)
-1. Imports required :
import weblogic.jndi.Environment;
import weblogic.management.MBeanHome;
import weblogic.management.WebLogicObjectName;
import weblogic.management.configuration.DomainMBean;
import weblogic.management.configuration.SecurityConfigurationMBean;
import weblogic.management.security.RealmMBean;
import weblogic.management.security.authentication.AuthenticationProviderMBean;
import weblogic.management.security.authentication.GroupEditorMBean;
import weblogic.management.security.authentication.UserEditorMBean;
import weblogic.management.security.authentication.UserPasswordEditorMBean;
import weblogic.security.providers.authentication.*;
0. Code to retrieve DefaultAuthenticatorMBean (this code is running inside WebLogic
server - I have it inside EJB):
DefaultAuthenticatorMBean authBean;
Context ctx = new InitialContext();
MBeanHome mbeanHome = (MBeanHome) ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);
//Find UserEditorMBean
DomainMBean dmb = mbeanHome.getActiveDomain();
SecurityConfigurationMBean scmb = dmb.getSecurityConfiguration();
RealmMBean rmb = scmb.findDefaultRealm();
AuthenticationProviderMBean[] providers = rmb.getAuthenticationProviders();
for (int i = 0; i < providers.length; i++) {
if (providers[i] instanceof DefaultAuthenticatorMBean) {    
authBean = (DefaultAuthenticatorMBean) providers;
break;
1. Create/Drop/Update users
to perform these tasks, the user must be logged in into weblogic and be in Administrators
group. Then, the code is as follows:
create user: authBean.createUser(username, password, description);
remove user: authBean.removeUser(username);
change user's description: authBean.setUserDescription(username, newDescription);
remove user from group: authBean.removeMemberFromGroup(groupname, username);
add user to group: authBean.addMemberToGroup(groupname, username);
2. Change other users' passwords (MUST BE ADMIN TO DO THIS - by Admin I mean be
a member of Administrators group)
authBean.resetUserPassword(username, newPassword);
3. Change your own password:
this is a bit trickier, because if you are not an admin, you can't change your
own password!!!! This is a part that I personally don't understand - seems like
a screw up on BEA's part. So, to allow users to change their own passwords, you
must change security context in the middle of processing to that of Admin user
and run this function as Admin user. Although a bit ackward, it's very easy to
do. Suppose you have two EJBs - EJB A and EJB B. EJB A does normal processing
for the user and always runs in logged in user's security context. Now, suppose
you want to add a method to EJB A to change current password. The method may
look like:
public void changePassword(String logon, String oldpwd, String newpwd)
throws some exceptions
Now, there is no way to do it in EJB A, because for most users, it will run in
a 'non-admin' security context. So, to get around it, you create another
EJB - EJB B. This EJB has one method:
public void changePassword(String logon, String oldpwd, String newpwd)
throws some exceptions
and one major difference - this EJB always runs in a secrity context of admin
user. To get an EJB B running 'as admin user', all you have to do in EJB A is
the following
EJB A:
public void changePassword(String logon, String oldpwd, String newpwd)
Hashtable props = new Hashtable();
props.put(Context.SECURITY_PRINCIPAL, "wlmanager");
props.put(Context.SECURITY_CREDENTIALS, "password");
// get context that with different credentials
Context ctx = new InitialContext(props);
EJBBHome home = (EJBBHome) ctx.lookup("EJBBHome");
EJBBLocal adminEJB = home.create();
adminEJB.changePassword(logon, oldpwd, newpwd);
adminEJB.remove();
of course, this poses a problem of hardcoding user id and password for admin user
in your application - you can come up with your own ways to secure that.
THAT's IT!!! You can use the method explained in part 3 to allow non-admin users
to do pretty much everything, however for the sake of security, I would definetly
vote against it and use part 3 to ONLY allow users change their own passwords
Enjoy
Andrey

I have a similar question, I would like to edit the artwork for EACH episode in the podcast, as well as have one artwork for the entire podcast series. Any suggestions? This is a podcast that I've created -- I did the same thing for a TV Show where I was able to do custom artwork for each episode, but not one single artwork for the entire series. Does anyone have suggestions of how i should proceed?
Recap:
One image for entire Podcast Series (or TV show)
Different Set of Images for each episode in Podcast. (Understand how to do this in TV show)
Thanks!

Similar Messages

  • Help downloaded game and need to find out how to add to iPod

    i downloaded the new ipod mini golf and i cant seem to find out how to add it to the thing please help.

    Welcome to Apple Discussions!
    1) Connect your iPod to the computer.
    2) Click the iPod in iTunes under Source (to the left).
    3) Click the Games tab.
    4) Select Sync all games
    5) Choose File --> Sync "iPod" to add the game
    You need to have a 5G iPod with video to play the game
    btabz

  • Trying to find out how to edit artwork, keywords, titles, and descriptions

    Trying to find out how to edit artwork, keywords, titles, and descriptions for my own video podcast that I have created for the iTunes store. My podcast shows on the first page in the itunes store (podcasts) for "forex" "forex training" and "forex education" under the name "fastpips", however I can't seem to find out how to change the title, for each podcast, the description, and keywords. I also want to add artwork to my podcast. I know how to do it under options for my own iTunes on my personal computer, but don't know how to edit it for others to see in the store itself. Thanks so much for any advice. By the way, I upload all my video podcasts to iTunes via ScreenCast.com I'm not sure if this will help, but here is the domain for the screencast files: http://www.screencast.com/users/ForexProFund/folders/FastPips.com%20Forex%20Trad ing%20and%20Forex%20Education

    I have a similar question, I would like to edit the artwork for EACH episode in the podcast, as well as have one artwork for the entire podcast series. Any suggestions? This is a podcast that I've created -- I did the same thing for a TV Show where I was able to do custom artwork for each episode, but not one single artwork for the entire series. Does anyone have suggestions of how i should proceed?
    Recap:
    One image for entire Podcast Series (or TV show)
    Different Set of Images for each episode in Podcast. (Understand how to do this in TV show)
    Thanks!

  • How can i add a new user and change user'password with javamail?

    how can i add a new user and change user'password from a mailserver with javamail?
    email:[email protected]

    Well user creation and updation is a system property..U need to go through that part...as it depends on the system you are hosting pout your application...
    if it is linux...u have to use some shell programming\
    bye for now let me know if this guides you or if you need some more stuff.
    bye

  • I have an iPhone 3G. I'm trying to find out how to retrieve accidentally deleted text messages on my phone. Is this possible?

    I have an iPhone 3G.  I need to know how to retrieve accidentally deleted text messages.  Is that possible?  Please say yes!  Thanks

    Myself and my girlfriend use the decipher textmessage program. She's on windows and I use the version for my macbook pro. It works cool and lets you save your text messages from your iphone to your computer. I've actually recovered a few deleted messages with it too which was helpful since I'm a laywer and needed them for work. Their site is:
    http://www.video-converter-mac.org/iphone-sms-recovery/
    Good luck! Hope you and your family are able to recover your sms messages!

  • How do I find out the file size of my photos, and change them to the size

    This will sound inane, but I cannot figure out where to find the file size of my photos in iPhoto. I need a jpeg of a certain file size and image size for my blog background, but can't figure out how to even start.

    If the limited quality options do not get you the file size you need export the full size image files to a folder on your Desktop and use Resize! to batch resize the image dimensions and file size (jpeg compression level) to what you need.
    Click to view full size
    With Resize! you can fine tune the pixel dimensions and file size.
    OT

  • How to find out who made inserts/updates/deletes made to a SQL Table

    I want to know WHO MAKES INSERTS/UPDATES/DELETES TO a particular SQL Table. Bascially I want to AUDIT ANY Edites made to a SQL 2008 TABLE. I need info such as WHO AMDE THE Updates i.e. the user first/lastname, When update was made, what row was updated etc...How
    can I do that with SQL 2008?

    One way to achieve that would be to use triggers to detect when a change is made to the table, and then insert a record into another table/database detailing what changed and who by.
    You'd need three triggers, one for insert, update and delete respectively, and for each of those you use the "inserted" and "deleted" tables (system tables maintained by SQL) to retrieve what has been done. To retrieve who made the change you can query IDENT_CURRENT
    which returns the last identity value for a specific table.
    See :
    Triggers -
    http://msdn.microsoft.com/en-gb/library/ms189799(v=sql.100).aspx
    Inserted & deleted tables -
    http://technet.microsoft.com/en-us/library/ms191300(v=sql.100).aspx
    INDENT_CURRENT -
    http://technet.microsoft.com/en-us/library/ms175098(v=sql.100).aspx
    There may be better / more up to date ways to do this, but I've used this method successfully in the past, albeit a long time ago (on a SQL 2000 box I think!).

  • How to stop an unauthorized user from changing my password.

    How do I block an unauthorized user from constantly changing my password?
    I had an old iPod Gen 4 stolen and someone from China is downloading Apps (I get email alerts when they download something and the last message said the computer used is registered in China).  I have changed the account password many times.  However, days later, I will get an alert email that my password was changed (not by me), or I will try to purchase something and my password will not work.  How else can I block this person from changing my password so he/she can use my account?  Will changing my user email address work?  Should I deactiviate all authorized computers to wipe them out?  I do not have any credit cards tied to my account, so they are only downloading free apps.

    Hi Gradux,
    Welcome to the Apple Support Communities! In this situation, I suggest contacting the application developer. The information on how to do that can be found in the following article.
    iOS: An app you installed unexpectedly quits, stops responding, or won’t open
    http://support.apple.com/kb/ts1702
    Contact the developer
    If you see the issue again, contact the developer of the app for help:
    Find the app in the App Store.
    Tap the app and tap Reviews.
    Tap App Support.
    I hope this helps,  
    -Joe

  • My screen on my phone is in a disabled mode and i cant get into my phone. i need to find out how i wipe my phone clean and start over

    my phone is in a diabled mode and it cant get into my phone anymore. i need to clear my phone off threw itunes but cant seem to figure it out

    http://support.apple.com/kb/HT1212?viewlocale=en_US&locale=en_US

  • How to Add Active Directory user to Admin Role

    Hi All,
    I am trying to figure out how to add a AD user to the Admin Role..
    I am connected to AD and can see the user (myself), however, when I try to add myself to the admin role, it says user not found.
    I go to Security Realms > myreals > Roles and Policies > Global Roles > Roles > Admin > View Role Condition.
    I see that the Administrators Group is already added. Now I click "add Conditions" and select "User" from the Predicate List and type in the user " Doe' John".
    On the next screen I get "user: John or Dow" does not exist.
    Another option could be to add the user to the Administrator group, but I couldnt figure out how to do that as well. When I navigate to the user under Users or Groups, I dont see an option to add that user to the Administrator group.
    Is it that you can only add users created in Weblogic to the Admin group?
    Any help on this will be very appreciated.
    Thanks in advance.

    I think I got it. I had to add the AD group the user is part of to the Admin role.

  • I'm trying to find out how to export my apple contacts to the Salesforce software and they need to be in a csv format and I don't know if this is possible and how to do it if it is?

    I'm trying to find out how to export my apple contacts to the Salesforce software and they need to be in a csv format and I don't know if this is possible and how to do it if it is?

    I think there are third-party programs which will do that, but you can also do it with Automator:
    See the links in my post, here: https://discussions.apple.com/message/22390873#22390873
    The file or clipboard contents will be in Tab Separated vars, so you'll have to open with a spreadsheet program and save as Comma Separated Vars format.

  • I have made a calendar in iCal on my MacBook Pro, but I cannot seem to find out how I can 'download' that same calendar on my iPhone and iPad. Does anyone know how to do this? Thanks in advance.

    I have made a calendar in iCal on my MacBook Pro, but I cannot seem to find out how I can 'download' that same calendar on my iPhone and iPad. Does anyone know how to do this? Thanks in advance.

    I have made a calendar in iCal on my MacBook Pro, but I cannot seem to find out how I can 'download' that same calendar on my iPhone and iPad. Does anyone know how to do this? Thanks in advance.

  • I am making a graduation video for my cousin using Final Cut Pro. I have photos layered over videos, and I was wanted to find out how you can add a border around the photos so they stand off of the video. Anyone know what I could do?

    I am making a graduation video for my cousin using Final Cut Pro. I have photos layered over videos, and I was wanted to find out how you can add a border around the photos so they stand off of the video. Anyone know what I could do?

    You would need an image editor to edit the images and add a border to the image first before importing them into Final Cut.
    Cheapest and very good image editor?
    PIxelmator.
    Located in the Mac App Store. $14.99 USD.
    Here is the Pixelmator website to give you an overview of the app.
    http://www.pixelmator.com/
    Good Luck!

  • I need to put electronic signature onto my desktop computer, and can't find out how to do this. ??

    i need to put electronic name onto my desktop computer and can't find out how to do this. Does anyone know how this is done? Thank you in advance.

    There are many ways to do it depending on the hardware that you have. Here is one simple way of doing it without any specific signature related hardware:
    http://www.productivity501.com/how-to-create-a-scanned-signature/357/
    I am an HP employee.
    Regards,
    Vidya
    Make it easier for other people to find solutions, by marking my answer “Accept as Solution” if it solves your problem.
    ***Click on "Thumbs up" button to the bottom right side of my post to say thanks!***

  • How do I find out how much storage space I have left on my macbook? can't find info in my "About this mac"

    I've been trying to find out how much storage space I have left on my old macbook but I can't find it in "about this mac".  Anybody...?

    YCGtkd wrote:
    tried the right click on MacIntosh and those choices are not avialable
    There will be.. after you Click on Get Info... another window will open that contains that information.

Maybe you are looking for

  • 2 monitors from MBP?

    Is there any way to run 2 external monitors from a single Macbook Pro with the unit closed? (so the external 2 monitors would be the only 2 monitors on) Thanks

  • I get the message "unable to process your request" when I try to login to a secure site

    I am trying to log in to a secure banking site. I have visited the site almost daily and now I am getting the message "unable to process your request try again later" so I wait and I continue to get the message. I have contacted the site to make sure

  • CiscoWorks LMS3.0 doesn't know the 2960 PoE type

    I have several PoE Catalyst 2960 WS-C2960-24PC-L When I added them to CiscoWokrs I found out that it doesn't know WS-C2960-24PC-L type. As a result they are unknown. The list of installed applications: 1. LMS Portal 1.0.0 2. CiscoWorks Assistant 1.0.

  • "Menu Photoshop file has changed outside..."

    The first time I saw this message (a few months ago soon after I started using Encore) I blissfully clicked on 'Yes'. That really messed things up so each time since I have clicked on the non-default 'No'. I was wondering why I should be getting this

  • Adding printer NEW AP extreme utility.app

    I want to add a printer that is connect directly to my PC and has a wifi connection, too.  My mac has always used the wifi to print, and with an old Netgear it worked fine.  Now with a brand new AP extreme (2015) it doesn't.  The utility app doesn't