How to check whether portal user exists or not using UM API.

Hi Experts,
Let us say i need to create an user account "PortalUser",i know how to create an user,setting first name,lastname,password for that.
but here before creating the portal user, i need to check whether that user exists or not.If user already exists ,then i  need to skip the below for creating the user.
IUserFactory userFact = UMFactory.getUserFactory();
IGroupFactory groupFact = UMFactory.getGroupFactory();
IRoleFactory roleFact = UMFactory.getRoleFactory();
IUser tuser = userFact.getUserByLogonID("PortalUser");
IUserMaint newUser = userFact.newUser("PortalUser");
newUser.setFirstName("PortalUser");
newUser.setLastName("Test");
newUser.setEmail("PortalUser.Testatgmaildotcom");
//Locale PortalLanguage = new Locale(Lang.toLowerCase(), "");
Locale PortalLang=new Locale("en");
newUser.setLocale(PortalLang);
newUser.save();
newUser.commit();
IUserAccount userAcc = UMFactory.getUserAccountFactory().newUserAccount("PortalUser", newUser.getUniqueID());
userAcc.setPassword("test1test$");
userAcc.save();
userAcc.commit();     
Thanks in advance.
Thanks
Sony.

Hi,
Try this code,
IUserFactory factory = UMFactory.getUserFactory();
IUser user = factory.getUserByLogonID(userId);
lastName = user.getLastName();
firstName = user.getFirstName();
refer this pdf,its very helpful
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/events/webinars-nw-rig/using%20the%20user%20management%20api%20with%20ep%20applications%20-%20webinar%20powerpoint.pdf
Regards,
Sunaina Reddy T

Similar Messages

  • How to check whether a Record Exists or not in Ztable

    Hi all,
    I have Req like this
    In ZTable i have 2 fields  * Legacy System , Legacy Material No*
    Environment Value is coming in one of the field in Idoc
    The logic is if the Environment Value is UK and a Record Exists on the ZTable for Legacy Sysyetm = Leg1 means i have send Legacy Material No , else  Send 01
    Please suggest me the process for this
    REgards
    Vamsi
    Edited by: Vamsi Krishna on May 19, 2009 5:31 PM

    Hi Michal / Aamir,
    Thanks for your replies.
    The ZTable is at R/3 side only, iam using RFC Lookup for this, but iam bit confuse on how to construct the logic to check whether there is a record Exists or not on Ztable
    Logic shld be If the Environment value is UK and a record exists on the Ztable for Legacy system "ABC" means then send Legacy material number else send 01
    In Table we will have the fields Legacy System   Legacy Material No  & Environment value is coming from Idoc itself( Ex: UK or US)
    Regards

  • How to check whether a file exists or not

    i am in an image uploading utility. i hav succesfully uploaded the image to the server directory (say /uploads). but when displaying the uploaded image, i wanna show the picture only if the image exits (bcoz for some records there is no image). so i hav used this code
    if(new File("uploads/1.jpg").exists())
         out.print("image exists");
    but its not working for me. i got it working fine when i give the full path "D:/Tomcat/webapps/diary/admin/uploads/1.jpg". but i think giving this absolute path is not an efficient method bcoz its a web application, bcoz i may not be able get the absolute path always. so how can i do this by specifieing the relative path
    help me ASAP if u can
    aleens

    Haii ameen
    This is one way to rectify your problem..
    if(new File("uploads/1.jpg").exists())
    out.print("image exists");
    instead of this u can write like
    <%
    ServletConfig cf=getServletConfig();
    ServletContext c=cf.getServletContext();
    if(new File(c.getRealPath("uploads")+"/test.txt").exists())
    out.print("image exists");
    %>If u are not clear of what it is done let me know..i will xplain to you furthur...
    Happy New Year
    Shanu

  • How to check whether a file exist in the program folder or not?

    Hi guys,
    how to check whether a file exist in the program folder or not? Let is say i recieve a file name from user then i want to know if the file is there not and act on that base.
    abdul

    Look at the class java.io.File and the .exists() method:
    http://java.sun.com/j2se/1.4/docs/api/java/io/File.html

  • How to check if a user exists in the system ?

    Dear Gurus,
    I want to check whether a user ID exists in the system after logon by using VBA. If the user ID exists, then I will update the user's information with external data by using the method user.change.
    When running below codes, error occurs and error msg is: "The persistent key for an business object instance of type USER has not been set. Cannot invoke method EXISTENCECHECK"
    How can I do to check the user ID existence ?
    Set oUser = oBAPICtrl.GetSapObject("user")
    oUser.ExistenceCheck "MyUserID", return:=oReturn
    Thanks and Regards,
    Bao Yan

    Mickey,
    I'm afraid I never did get this to work properly. However, in the way of all bad/good (delete as appropriate) programmers eveywhere I worked around this problem. I was using this code in Banner.asp to change the view based on the user group so if a given session variable was set a user would see a different view. It works fine with no slow down on the page and you should be able to adapt it to what you need.
    Hope this helps.
    Neville
    Note: Application variables are ones I have defined in config.xml.
    Code follows:
    <!--START:INC\common\getgroup.asp-->
    <% 'NAH 29/03/2004 ' 'This check the to see if the current user has the group in their membership that has been defined as the group to provide an alternative view of the portal.' 'The group variable is defined in the config.xml as "ALTVIEWGROUP"'
    'Do not do this is we have already matched the group'If Session("groupMatch") <> "1" and Session("groupMatch") <> "2" then
    Dim pGroup
    pGroup = Application("ALTVIEWGROUP") Set Session("groupMatch") = nothing
    Dim Plumtree
    Set Plumtree = Server.CreateObject("ADODB.Recordset") Plumtree.ActiveConnection = "Driver={SQL Server};Server=" & Application("DBSERVER") & ";Database=" & Application("PLUMTREEDB") & ";" Plumtree.Source = "SELECT GROUPID FROM " & Application("PLUMTREEDBUSER") & ".PTGROUPMEMBERSHIP WHERE (USERID = " & strUserID & ") AND (GROUPID = " & pGroup & ")" Plumtree.CursorType = 3 Plumtree.CursorLocation = 2 Plumtree.LockType = 1 Plumtree.Open()
    'If there are records we should have a match otherwise set the session varible to no match.' If Plumtree.EOF then Session("groupMatch") = "2" Else 'By getting here the user should have the matching group but complete one final check to make sure' If cInt(Plumtree.Fields.Item("GROUPID").Value) = cInt(pGroup) then Session("groupMatch") = "1" Else Session("groupMatch") = "2" End If
    End If
    Plumtree.Close() Set Plumtree = Nothing
    End if%><!--END:INC\common\getgroup.asp-->

  • How to check whether transport path exist between two systems in sld??

    Hi,
         I have two systems namely 'A' and 'B' and created business systems for both of them.Then i created transport path between the two systems.How i check whether what i have done is right in SLD.

    <b>WRT to CMS</b>
    am not sure with this but u can try:
    1. Start CMS: http://<host>:<J2EE Engine http port>/webdynpro/dispatcher/sap.com/tcSLCMS~WebUI/Cms.
    2. Goto lansdscape configurator and check there
    Message was edited by:
            Prabhu  S

  • How to check whether a user session is null or not

    Hi
    I am using Jdeveloper 11.1.2.2
    I have a use case of running some Junit test case, this is the problem I have :
    There are some Junit tests which are written for some VO's. While testing insert and update operation in Junit there is two mandatory columns Created by and Updated by to be entered for committing into the database.
    These values are taken from the UserName of the current UserSession .
    So for getting the these values for each user I thought of displaying a JPanel before the test is run, where the user enters the Username and password which is validated and the user is verified.
    First, I need to check whether there is a session present or not. For checking this, I wrote a createUserSession() and did like this inside it :
    if(fixture.getApplicationModule().getSession().getUserData().isEmpty())If so to show the Jpanel and get the user details and verify the user.
    But while running the test itself I found that the session is already present, now I just have to input the values based on who is the user.
    But Junit doesn't run the tests in the order in which the test are written. So I have to call this in all the test cases.
    The Question is :
    How can I check whether the session is already present or not, so that I don't have to ask the user every time while every test is running to enter the Username and Password ?
    Thanks,
    Nigel.
    Edited by: Nigel Thomas on Jul 30, 2012 10:26 AM

    Hi,
    wondering why don't you create test users and then automatically log them in as Jan Vervecken did on the threads I pointed you to. This way your test cases run without user interaction. To test if a session exists for a user, I would put a custom property into user data. If this property exists, the user session is an existing one. However, make sure the information you save into the user data survives passivation as otherwise the information you get out of this is not accurate. See: http://tompeez.wordpress.com/2011/07/08/jdev-always-test-your-app-with-applicationmodule-pooling-turned-off/
    Frank

  • How to check whether the user has a certificate or not?

    Hi everyone.
    We're currently finishing a web project and the last step is to check whether users accessing the application have a valid certificate or not.
    Users with a valid certificate can access all the data. Users without any certificate installed on their browsers may still proceed, but they won't be able to see all data. Please note that the lack of a certificate doesn't mean an error - it's just another use case.
    Is there any way to check whether users have a certificate installed on their browsers?
    Thanks in advance.
    Edit: sorry, I forgot to post some tech details. We're using Struts 1.2 on a Tomcat 5 app server.
    Message was edited by:
    advaca

    I am not sure how Tomcat handles this, but you need to use two-way (mutual authentication) request but not enforce SSL between Tomcat and the client browser. This will make the browser prompt the user for the cert they want to send. Then you'll need to tackle the other part of your problem, getting the correct content displayed depending on whether the user sent a cert or not. I'm even less help there than I was on the first part of your question.
    So, yeah - good luck with that
    Lee

  • How to check whether a node exist in a Particular Level. (xmltype)

    hi,
    please help me to check whether a particular node exists in one level.
    for eg
    I have the following xml
    <map>
         <entry>
              <key>
                   heading1
                   </key>
              <map>
                   <entry>
                        <key> sub1 heading1</key>
                        <value> sub1 heading1 value  </value>
                   </entry>
                   <entry>
                        <key> sub2 heading1 </key>
                        <value> sub2 heading1 value  </value>
                   </entry>
              </map>
         </entry>
         <entry>
              <key>
                   heading2
                   </key>
              <map>
                   <entry>
                        <key> sub1 heading2</key>
                        <value> sub1 heading2 value  </value>
                   </entry>
                   <entry>
                        <key> sub2 heading2 </key>
                        <value> sub2 heading2 value  </value>
                   </entry>
              </map>
         </entry>
    </map>i need to check how many heading exists in this xml.
    I am checking like
            i:=1;
         l_section := ip_xml.extract('//map/entry');
         WHILE l_section.existsnode('entry[' || i|| ']') = 1 LOOP
              // extract the key name within entry tag
                  // print the key name.
    i:=i+1;
         end loop;but iam getting all the key name like
    heading1
    sub1 heading1
    sub2 heading1
    heading2
    sub1 heading2
    sub2 heading2
    I need only heading1 and heading2. how can I check whether a particular node exist in particular level.
    first level , second level etc. Please help

    but iam getting all the key nameThat's because you're using a descendant axis : //map/entry
    SQL> DECLARE
      2 
      3   ip_xml  xmltype := xmltype('<map>
      4       <entry>
      5            <key>
      6                 heading1
      7                 </key>
      8            <map>
      9                 <entry>
    10                      <key> sub1 heading1</key>
    11                      <value> sub1 heading1 value  </value>
    12                 </entry>
    13                 <entry>
    14                      <key> sub2 heading1 </key>
    15                      <value> sub2 heading1 value  </value>
    16                 </entry>
    17            </map>
    18       </entry>
    19       <entry>
    20            <key>
    21                 heading2
    22                 </key>
    23            <map>
    24                 <entry>
    25                      <key> sub1 heading2</key>
    26                      <value> sub1 heading2 value  </value>
    27                 </entry>
    28                 <entry>
    29                      <key> sub2 heading2 </key>
    30                      <value> sub2 heading2 value  </value>
    31                 </entry>
    32            </map>
    33       </entry>
    34  </map>');
    35 
    36  BEGIN
    37 
    38    for r in (
    39      select heading, headno
    40      from xmltable( '/map/entry/key'
    41                     passing ip_xml
    42                     columns heading varchar2(30) path '.'
    43                           , headno  for ordinality )
    44    )
    45    loop
    46      dbms_output.put_line('Heading '||r.headno||' = '||r.heading);
    47    end loop
    48    ;
    49 
    50  END;
    51  /
    Heading 1 =
                   heading1
    Heading 2 =
                   heading2
    PL/SQL procedure successfully completed

  • How to check whether a user has permission to create term in Taxonomy Term Store using CSOM ?

    I want to check programmatically whether the current user is a Term Store Administrator or not.

    I am not sure how Tomcat handles this, but you need to use two-way (mutual authentication) request but not enforce SSL between Tomcat and the client browser. This will make the browser prompt the user for the cert they want to send. Then you'll need to tackle the other part of your problem, getting the correct content displayed depending on whether the user sent a cert or not. I'm even less help there than I was on the first part of your question.
    So, yeah - good luck with that
    Lee

  • How to check whether a table exists in database

    test9997 is table already made in database with 3 columns :1st-varchar,2nd-number,3rd-number
    declare
    var1 varchar2(20);
    var2 number(20);
    var3 number(20);
    begin
    plvar1 :='this is again pl/sql';
    plvar2 := 12;
    plvar3 := 13;
    IF (???? condition for existence of table say test1111??????) then
    create table test1111(
    var1 varchar2(20);
    var2 number(20);
    var3 number(20);
    insert into test1111(plvar1,plvar2,plvar3);
    else
    insert into test1111(plvar1,plvar2,plvar3);;
    end if;
    end;
    in the above code i want to check existence of a table and insertion or updation will be based on it after creation if it doesnt exist.
    how to do it
    please help asap

    You're in the wrong forum (this one is for issues with the SQL Developer tool). You'll get more answers in the SQL And PL/SQL forum.
    Have fun,
    K.

  • Want to check whether cost center exists or not during payroll process ?

    Dear All,
    Requirement is to throw an error for an employee during payroll run if the cost center does not exist.
    I guess this may be achieved by PCR only.  There is an operation OUTWPCOSTC which can help.
    Issue is that there are parameters like VALEN and VAOFF which need to be taken care of while using OUTWPCOSTC.
    Also, when cost center is not assigned, its value in WPBP is BLANK.  How to query a BLANK value in PCRs?
    Can any help on this with an complete example?
    Regards,
    Ankit

    Hi Ankit,
    Try with PCR
    VALEN 1
    OUTWPCOSTC
    Update the PCR in sub schema COPY  Z002                  Edit basic data
    000040 WPBP                        Read Work Center/Basic Pay Data
    000050 GON                         Continue if Data is Complete
    000060 ACTIO ZQ14 GEN              Check if cost centre exits
    000070 BLOCK END                   Edit basic data
    This will help you while runing the Payroll.
    Thanks & Regards
    Vikram Mali

  • How to Check whether laptop is OEM or Not ?

    I had bought a  Envy 15 notebook through flipkart. But due to technical problem I had refreshed my pc using HP recovery. At last I cant activate windows 8. When I contacted Microsoft technical support I had given my product ID and they told me that it was not a product of OEM. Whats the solution for this problem ?

    Hi,
    It will blow air out. You can use you hand or a piece of tissue to check. Normally fan will only work when machine is getting warmer. You may run machine for 10 or 15 mins then check. BUT making beeping noise at startup is not a good news, what is the actual noise ? How many times ?
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • How to check whether file exist or not?

    hello,
    i wanted to know that how can i check whether a file exist or not independent of underlying Operating system?
    please help .
    Thank you.

    Use exists() on a File instance.

  • Where to check whether the user is Admin  or developer?

    how to check whether the user is Admin or developer????? after he sign's in......I want to use role based login!!!!

    Login into a workspace or login into an application?
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

Maybe you are looking for