Controlling report output based on current user

Hi all,
I am building a small app with APEX for a sales team.
We have the site and app hosted by another company.
I have built a report showing sales summary for the company. The problem is that the report is showing all sales for all sales people.
What I want is for the report to show data based on the user that is logged in, so that the user only sees his items.
In fact, this would be a useful thing to learn for me, because I could use this functionality on several other pager, so this will be a good example for other situations.
So far I have:
I have a database table that keeps track of the sales reps.
Each sales rep in that table is assigned a unique EMP_id, which is an autonumber column of that table, and is also the primary key.
The table also contains a column named: "User login Name" which is their login ID (the one they use to log into the application.
Possible solution (I think):
when user logs into APEX, retrieve their EMP_id from the EMP table based on their login name,
Hold the EMP_id in a variable for the duration of the session,
pass the variable to the SQL query for the report in the where clause.
Is this a good solution? or is there a better way to do this?
Can anyone advise on how to get this done please,
Thank you.

Hi,
Sorry - I guess I should have said where to create the function!
You can keep those steps or keep with your own method as both should return the value you need. I usually store the result of that value in G_USER - similar to Tyson's method - when the user logs in and then use :G_USER wherever I want to use it in filters etc. However, if I need to create SQL Views, I have to use the GETCURRENTUSERID() function instead.
Andy
ps - I used MIN() in the function to ensure that I only get one value returned. The method SELECT .... INTO .... only allows us to set a variable to one value and, sometimes, more than one value is returned by the SELECT statement and this would generate an error. Of course, there should be just the one value that matches the current user, but I always assume the worst! The statementS:
SELECT MIN(EMP_ID) into user_id FROM S_USERS WHERE UPPER(LOGIN_ID) = UPPER(v('APP_USER'));
user_id := CASE WHEN user_id IS NULL THEN 9999999999 ELSE user_id END;could also be written as:
SELECT EMP_ID into user_id FROM S_USERS WHERE UPPER(LOGIN_ID) = UPPER(v('APP_USER')) AND ROWNUM = 1;
user_id := CASE WHEN user_id IS NULL THEN 9999999999 ELSE user_id END;or
SELECT NVL(MIN(EMP_ID), 9999999999) into user_id FROM S_USERS WHERE UPPER(LOGIN_ID) = UPPER(v('APP_USER'));

Similar Messages

  • Control analog output based on analog input

    Dear forumers,
    I am pretty new to the labview programming so excuse me if this was posted before.
    I use: Labview 8.5 + PCI 6229
    I want to create a real time feedback: to control analog output based on analog input. The task is very simple - if the ai1 (analog input 1) voltage is larger than a constant, then decrease the voltage of the ao1 (analog output 1) by a constant. Otherwise increase the voltage of ao1 by the same constant.
    All should work for 10 seconds.
    I have tried to implement this using 2 daq asistants and various methods. The problem is that I get the whole signal recorded from the ai1 ( 10 seconds) and then modified and released to the output (another 10 seconds). The execution takes 20 seconds instead of 10 and it is not realtime at all.
    Is it a must to make vi in "run continuous" mode to make it work ?
    Please help :}.
    I am attaching 2 examples.
    1. Main idea what I am trying to accomplish
    2. Very simple example that still does not work in real time simultaneously.
    Attachments:
    example-main.vi ‏180 KB
    example-simple.vi ‏147 KB

    nooto wrote:
    Thank you for your suggestion.
    I understand the simple arithmetic you are talking about. However I do not understand why it takes 20 seconds instead of 10 to complete the task. In other way to say - why it reads the whole input first (10 seconds) then write the output ( 10 seconds).
    Why doesn't ir read and write simultaneously?
    If I use Elapsed Time function - what feedback response time can I expect ? Is it good to use Elapsed Time if i need fast response time? In my application i would I need about 1 milisecond response time. Currently in the example the rate is 50 Hz, later I would like to change the rate to 1000.
    You simply don't understand the underlying paradigm of LabVIEW -
    dataflow. You have a dependency between the first DAQ Assistant and the
    second. The second simply will not start until the first finishes. There
    is no way around that given your condition that the output depends on
    what you read.
    If you want 1 millisecond response time then you will have to swithc to a real-time OS. Windows does not have that kind of resolution and there is way to much jitter.

  • How can I filter a Sharepoint 2007 libarry list based on current user login?

    Hi all.
    I would like to know how I can filter a SharePoint library list based on current user login.
    Suppose I have created the followings:
    1) A SharePoint form library containing bunch of uploaded InfoPath form data.
    2) The InfoPath form template contains a promoted text field called "TargetUser" to store user domain login (ex: DOMAIN\JOE) and every InfoPath form file in the library has a valid domain name stored in the "TargetUser" field.
    I have created a custom view for the form library and would like to filter this view so only items whose "TargetUser" field matches current user's login ID are displayed.
    I went to Edit View page to customize the view and tried to use the [Me] function but I got a "Filter value is not a valid text string" message instead when clicking OK. Apparently [Me] returns a Person/Group data type and the filter cannot compare its value
    to that of "TargetUser".
    I tried using text functions (ex: TEXT([Me],"") hoping to extract default string value from [Me]. The filter accepts the parameter without any error but the resulting fitlered list does not display any items at all.
    I have googled this subject for hours but I have not found any solution.
    It would be greatly appreciated if anyone can help me to create a functional filtered list.
    FYI, my SharePoint 2007 installation is just WSS 3.0 + Form Server. I do not have MOSS 2007 (so no MOSS 2007 web parts or web services).
    Thank you.
    Jason

    Here's what I usually do in order to accomplish this.  Ultimately you'll need to have 2 different fields.  There's the one you already have, with DOMAIN\username stored in it.  Then you'll need an additional field as a "person" column type. 
    Call it "TargetPerson" or something.
    Create a sharepoint designer workflow that runs each time an item is created or changed.  One action:
    Set FIELD to VALUE.
    The first FIELD is "TargetPerson", the VALUE is your "TargetUser" field. 
    Once this is done, then the person value is stored in the person field.  This is the field that you can filter by "TargetPerson" is equal to [Me]
    Laura Rogers, MCSE, MCTS
    SharePoint911: SharePoint Consulting
    Blog: http://www.sharepoint911.com/blogs/laura
    Twitter: WonderLaura

  • Dynamic LOV based on Current user

    How do i make a dynamic LOV based on the user id of the current user.
    Also how to insert values from a form into a database
    Can anyone please help me out.
    Thanks

    Use portal.wwctx_api.get_user to get the currently logged in userid.
    The simplest example of a form manipulating data is to create the form based on a table. All DML works automagically. You can base your form on a procedure with dummy columns and do your own DML if you wish. Lots more flexibility that way...

  • Is it possible to filter list view based on current user logged in

    Hi,
    Is it possible to filter the list view results based on the current user logged in. I have a scenario wherein i want to show only those list items to the user which contains his/her name under the column Approver (a list column).
    So if i login to the page, then only those requests should show up which has my name as the Approver, and so on.
    Is it possible please ?
    Thank you.

    Hi Prajk, you could use audience targeting for this. An alternative would be to create a view and add a filter so that "Approver" is equal to [Me]
    cameron rautmann

  • Different Report Output based on different tabstrips on selection screen

    Hi all,
    I have a selection screen which has 3 tabstrips.
    The screen nos are 101,102  and 103.
    Now in each tab there are different input parameters and based on each tab there will be 3 different outputs.
    i.e when I click on tab1 and give the required inputs i will get 1 report output.
    similarly I will get different ouput in the other 2 tabs.
    Can any one suggest some solution how to achieve this.
    Thanks and Regards
    Nazmul Azad

    Look for documentation at [SELECTION-SCREEN - TABBED BLOCK |http://help.sap.com/abapdocu/en/ABAPSELECTION-SCREEN_TABBED.htm]
    Adapgt the sample provided, and in the START-OF-SELECTON event add a CASE/WHEN to execute whichever report you want based on mytab-dynnr value.
    Regards,
    Raymond

  • Exception (colouring cells) in report output based on formula.

    Hi Gurus,
    I want to colour my cells in report output. But this coloring is not so simple. It has to be done based on a formula.
    Lets say i have material in rows and sales value by period in columns.
    .......................Jan'08......Feb'08.......Mar'08.....Apr'08
    Material A...........100..........120............105.........140
    If Feb'08 values is greater than 0,02*Jan'08 value than ---> Feb'08 has to be coloured as green. etc.
    Is it possible to define such a rule for the exception?
    Thanks
    S.P.

    Hi Reddy,
    I am using bex 7.0.
    I tried that also.
    I created another formula in columns with name "Difference" and it calculates the difference.
    Report looks like as below:
    Material.....Jan'08.......Feb'08.....Difference
    ABC............100............120.............0,2
    Now, I have to colour Feb'08 column, based on the value under Difference column. But it does not work.
    In Exception settings; from Definition tab, I selected Difference column (exception is based on).
    In Display tab, I select Feb'08 column.
    But it does not work.
    Any idea?
    Thanks
    S.P.

  • Blazeds + Spring security: fetch data based on current user

    Hi,
    I'm currently learning flex by trying to build an application with
    flex, blazeds and Spring. My application lets users log on using
    spring security (which I will probably combine with
    AcegiLogonCommand). I would like my assemblers to return different
    data based on which user is currently logged on (for instance to show
    that specific user's to-do list). To do this, I added a userId
    property to my spring security principals (by subclassing
    org.springframework.security.userdetails.User)
    and added user_id columns to user-specific data in the database. Now
    I would like to know how I can get the currently logged on user in my
    assembler so I can use its userId to fetch the user's data.
    Is the assembler the right place to decide which data to send to my
    flex application? If so, can anyone tell me how to determine which
    user is currently logged on in my assembler? If not, what would be the
    recommended way of dealing with user-specific data in my database in
    combination with blazeds?
    The only examples I have been able to find on the Internet so far only
    use different roles to determine what a user is or is not allowed to
    do, I have yet to find any examples where users store and retrieve
    user-specific data.
    Kind regards,
    Jeroen

    Hi,
    There is a field “Target Audience” in list whenever “Target Audience” is enable in “List Settings”, it accepts the name of a SharePoint group.
    For your requirement, you will need to get the name of the group which the current user belongs to. Then perform a query in a specific list to get all the items that
    contains the specific value in “Target Audience” field.
    Here is a code snippet about how to set Target Audience for an item, there are code lines about
    how to get the value of a “Target Audience” field:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/a3ac41d8-42e9-4ec7-999f-036c4b06d3e2/programatically-set-target-audience-in-list-item
    A method about checking whether the current user is a member of the specified group:
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.iscurrentusermemberofgroup.aspx
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

  • Filter Project Server custom field based on current user?

    I've got a Project Server 2013 custom field, and I'd like to create a view that only shows me projects where the value in that custom field equals the current user. Simply put: I'm trying to find functionality similar to the [Me] filter in SharePoint.
    Apparently, simply using [Me] doesn't work. How can I fix this?

    I am trying to do something similar. were you able to find a solution to this? I am assuming no. 
    Parthiv Bhuta . Consultant

  • Powershell: Add registry value based on current user

    I would like to automate a network printer install that uses secure print. I can push the actual install out through group policy, but I need script that will assign each persons unique ID number to the printer settings. 
    Get current user name
    Check that user name against a spreadsheet or .txt file list. This list would have hundreds of unique user names in column A, and a unique ID number in column B.
    Example:
    Column A (username)               Column B (ID Number)
    User 1 
          123456
    User 2
          789101
    Write the ID number in column B to a specific registry value.
    Any idea's??

    You would use New-ItemProperty or Set-ItemProperty to write a registry value. New-* will allow you to set the value type (you can use -Force if it already exists). Here's an example of using Set-*:
    # Set a value named 'ValueName' in the key stored in $RegPath to 'ValueGoesHere'
    Set-ItemProperty -Path $RegPath -Name ValueName -Value ValueGoesHere
    If you need to get a value, you can use Get-ItemProperty:
    # Get all values for the Windows Update service's key:
    Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\services\wuauserv
    # Just get the start value (returned as an object with start and extra PS properties):
    Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\services\wuauserv -Name Start
    # Just get the start value (just the value):
    Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\services\wuauserv | select -exp Start
    (Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\services\wuauserv).Start

  • Fixed report period based on current date

    I want to create a report containing records over a fixed period without using a date parameter. As a example I would like the report to continually draw on data that is no more than say ten years from the current date.
    E.g. Current date (xx/xx/2008) to (Current date - 10 years) or xx/xx/1998 then next year the formula would automatically adjust to current date (xx/xx/2009) to (Current date - 10 years) or xx/xx/1999.
    I am only a novice when it comes to designing reports so please bear that in mind.

    Hi,
    Create a RecordSelectionFormula and subtract 10 years from the current date with the DateAdd formula.
    E.g.
    //DateAdd (intervalType, nIntervals, startDateTime)
    {Table.Date} > DateAdd ("yyyy", -10, CurrentDate)
    The DateAdd function has more interval types, so you can subtract months, days, hours as well. Check the CR help file and search for DateAdd for details.
    Cheers,
    Fritz

  • ALV report output to be send to the respective users through email

    Hi Gurus,
    My requirement is to send the ALV report output to the respective users Email ID (Lotus notes) when the report runs in background.
    Could any one suggest me with sample coding, How to send a ALV report output to the respective email ID's ( Suggest me the FM that used to send a internal table)
    Regards
    Paul

    Hi Paul,
      Here for u the sample code:
    <b>call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           exporting
                document_data              = gd_doc_data
                put_in_outbox              = 'X'
           importing
                sent_to_all                = gd_sent_all
           tables
                packing_list               = it_packing_list
                contents_txt               = it_message
                receivers                  = it_receivers
           exceptions
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                others                     = 8.
    Store function module return code
      gd_error = sy-subrc.
    Get it_receivers return code
      loop at it_receivers.
      endloop.</b>
    Hope this helps you.Reply for queries
    Regards,
    Kumar.

  • Need to print Current user Name in crystal report in B1

    Hi all,
    In Crystal reports there are 2 current user fields
             CurrentCEUserName
    and   CurrentCEUserID
    I have tried to add these fields to the footer of my reports, but no information comes out.
    Is there any way to find out the current user and print their user name on the report?
    Users have 2 id's.  Where can I find this info and add it to the report.
    A) the windows user id if possible
    B) the SAP user id
    Thanks
    Chris

    HI,
    If you want SAP user id ,add OUSR table and pick user id from that table.
    or check http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=14295
    Thanks,
    Neetu

  • Find out reporting line of current user from org model

    Hi all,
    Does anybody know a standard function module (or some pieces of code) that queries the organization model (pposa_bbp) of SRM and returns the reporting line of the current user? For example, the function should return the current user's supervisor and his  supervisor recursively until the top of the company management.
    Thanks!
    Jay

    Hi,
    Here is the Set of FM that you can use for "REPORTING STRUCTURE" in SRM Org structure.
    BBP_OM_STRUC_GET_MGR_FROM_ORG
    BBP_OM_STRUC_GET_ORG_FROM_POS
    BBP_OM_STRUC_GET_ORG_FROM_USER
    BBP_OM_STRUC_GET_POS_FROM_USER
    BBP_OM_STRUC_GET_PUSR_FROM_PGP
    BBP_OM_STRUC_GET_UNITS_OF_MGR
    BBP_OM_STRUC_GET_USER_FROM_ORG
    BBP_OM_STRUC_GET_USER_FROM_POS
    Cheers, Renga
    ***Award points for usefull answers***

  • How to set Current User in moss 2007 for Authentication....

    Hi Team,
    We have current running website where we have user id to login but now requirement is that user will login with his Email address. Email is stored in active directory, I'm able to login with fba authentication.  
    I'm able to retrieve the user id of current user using Email but
    I am NOT able to set that user id for current user for further authentication using Moss 2007.
    Please find the source code for login and authentication page:
    //---------------------------Login Page--------------------//
        public partial class Login : System.Web.UI.UserControl
            #region Decleration
            string LoginStatus = null;
            string UserCurrent = null;
           static SPUser siteuser;
           // private static string _randomNumbercheck;
            //private static bool IsLoggedin;      
            Random random;
            #endregion       
            #region Page Load
            protected void Page_Load(object sender, EventArgs e)
                this.hplchangepw.Visible = false;
                this.hplmytask.Visible = false;
                string desturl = SPContext.Current.Site.Url;
                if (!IsPostBack)
                    try
                        string str;
     SPWeb web = SPContext.Current.Web;
                             SPUser siteuser = web. .CurrentUser; 
                        //SPUser siteuser = spWeb.EnsureUser(username);
                        str = (siteuser == null ? "" : siteuser.ToString());
                        this.Login.TitleText = "";
                        this.Login.DestinationPageUrl = desturl;
                        //if (HttpContext.Current.Request.UrlReferrer != null)
                        //    if (this.Page.User.Identity.IsAuthenticated && ((Session["test1"].ToString() == _randomNumbercheck) || LoginControl.Class1.IsLoggedIn))
                         if (this.Page.User.Identity.IsAuthenticated)
                               // _randomNumbercheck = "";
                                this.hplregister.Visible = false;
                                this.hplforgetpassw.Visible = false;
                                this.hplchangepw.Visible = true;
                                this.hplmytask.Visible = true;
                                this.Login.Visible = false;
      if (str.StartsWith("fba_"))
                                    string name = str.Split(':').GetValue(1).ToString();
                                    LoginnameLbl.Text = "<b>" + name.ToString() + "</b>,<br><br>Haryana Urban Development Authority Welcomes
    You. <br><br><br><b><i>\"In The Service Of Masses\"</i></b>";
                                else
                                    string name = str.Split('\\').GetValue(1).ToString();
                                    LoginnameLbl.Text = "<b>" + name.ToString() + "</b>,<br><br>Haryana Urban Development Authority Welcomes
    You. <br><br><br><b><i>\"In The Service Of Masses\"</i></b>";
                            else
                                this.hplchangepw.Visible = false;
                                this.hplmytask.Visible = false;
                                this.Login.Visible = true;
                                LoginnameLbl.Text = "";
                                HttpContext.Current.Session.Clear();
                                HttpContext.Current.Session.Abandon();
                    catch (Exception ex)
                        //HttpContext.Current.Session.Clear();
                        //HttpContext.Current.Session.Abandon();
            #endregion
            #region Get Audit Informations
            public void GetUserInfo()
                try
                    string user = Login.UserName;
                    SPSecurity.RunWithElevatedPrivileges(new SPSecurity.CodeToRunElevated(delegate()
                        using (SPSite oSite = new SPSite(SPContext.Current.Site.ID))
                            using (SPWeb web1 = oSite.OpenWeb(SPContext.Current.Web.ID))
                                SPListItem item = null;
                                SPListItemCollection listItems = null;
                                web1.AllowUnsafeUpdates = true;
                                siteuser = web1.EnsureUser(Session["User"].ToString());// spWeb.EnsureUser(login);
                                listItems = web1.Lists["Audit_Trail"].Items;
                                item = listItems.Add();
                                item["User_ID"] = UserCurrent.ToString(); //Request.ServerVariables["AUTH_USER"];
                                string ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                                if ((ip == null) || (ip == "") || (ip.ToLower() == "unknown"))
                                    ip = Request.ServerVariables["REMOTE_ADDR"];
                                item["IP_Address"] = ip;
                                item["Login_Date"] = System.DateTime.Now;
                                item["Login_Status"] = LoginStatus.ToString();
                                item.Update();
                                web1.AllowUnsafeUpdates = false;
                                web1.Dispose();
                                oSite.Dispose();
                catch (Exception ex)
            #endregion
            #region MD5Encryption
            private string MD5Encryption(string strToEncrypt)
                System.Text.UTF8Encoding ue = new System.Text.UTF8Encoding();
                byte[] bytes = ue.GetBytes(strToEncrypt);
                // encrypt bytes
                System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
                byte[] hashBytes = md5.ComputeHash(bytes);
                // Convert the encrypted bytes back to a string (base 16)
                string hashString = "";
                for (int i = 0; i < hashBytes.Length; i++)
                    hashString += Convert.ToString(hashBytes[i], 16).PadLeft(2, '0');
                return hashString.PadLeft(32, '0');
            #endregion
            #region Generate Random Code
            private string GenerateRandomCode()
                random = new Random();
                string s = "";
                for (int i = 0; i <= 6; i++)
                    s = string.Concat(s, this.random.Next(10).ToString());
               // _randomNumbercheck = s;
                return s;
            #endregion
            #region Generate Random String
            public string GenerateHashKey()
                StringBuilder myStr = new StringBuilder();
                myStr.Append(Request.Browser.Browser);
                myStr.Append(Request.Browser.Platform);
                myStr.Append(Request.Browser.MajorVersion);
                myStr.Append(Request.Browser.MinorVersion);
                myStr.Append(Request.LogonUserIdentity.User.Value);
                SHA1 sha = new SHA1CryptoServiceProvider();
                byte[] hashdata = sha.ComputeHash(Encoding.UTF8.GetBytes(myStr.ToString()));
                return Convert.ToBase64String(hashdata);
            #endregion
            #region Check User Authentication
            protected void Login_Authenticate(object sender, AuthenticateEventArgs e)
                Utility hu=new Utility();
                int CheckValue = 0;
                string user = Login.UserName;
                if(user.Contains("@"))
                    CheckValue=1;
                //Encrypted Password
                string HPassword = hash.Value;
                // Verify that the username/password pair is valid
                SqlConnection con = new SqlConnection();
                SqlCommand cmd = new SqlCommand();
                con.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["FBAPortalConnection"];
                if (con.State == ConnectionState.Closed)
                    con.Open();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "sp_Portal_ValidatePortalUser";
                cmd.Connection = con;
                cmd.Parameters.Add("@ID", SqlDbType.NVarChar, 256).Value = Login.UserName;
                cmd.Parameters.Add("@Password", SqlDbType.NVarChar, 300).Value = HPassword.ToString();
                cmd.Parameters.Add("@CheckVal", SqlDbType.Int).Value = CheckValue;
                cmd.Parameters.Add(new SqlParameter("@P_Return", SqlDbType.NVarChar, 256));
                cmd.Parameters["@P_Return"].Direction = ParameterDirection.Output;
                cmd.ExecuteNonQuery();
                string CurrentUserName = cmd.Parameters["@P_Return"].Value.ToString();
                cmd.Dispose();
                con.Close();
                //int x = hu.ValidatePortalUser(Login.UserName, HPassword.ToString(), CheckValue);
                if (CurrentUserName != "0")
                    Page.Session["User"] = CurrentUserName;
                    string UserName = Session["User"].ToString();
                    UserCurrent = UserName;
                    LoginStatus = "Successfull";
                    GetUserInfo();
                    e.Authenticated = true;
                    //Session["CustomAuthKey"] = MD5Encryption(Request.ServerVariables["Remote_Addr"] + Request.ServerVariables["Http_Cookie"] + Request.ServerVariables["Auth_User"]);
                    Session["CustomAuthKey"] = MD5Encryption(Request.ServerVariables["Remote_Addr"] + Request.ServerVariables["Http_Cookie"] + UserCurrent.ToString());
                    FormsAuthenticationTicket tkt;
                    String cookiestr;
                    HttpCookie ck;
                    tkt = new FormsAuthenticationTicket(1, UserName, DateTime.Now, DateTime.Now.AddMinutes(15), false, GenerateHashKey());
                    cookiestr = FormsAuthentication.Encrypt(tkt);
                    ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
                    ck.Path = FormsAuthentication.FormsCookiePath;
                    Response.Cookies.Add(ck);
                else
                    // Username/password are not valid...
                    Login.FailureText = "Invalid Username / password";
                    e.Authenticated = false;
            #endregion
            #region Login Error
            protected void Login_LoginError(object sender, EventArgs e)
                // Determine why the user could not login
                Login.FailureText = "Your login attempt was not successful. Please try again.";
                // Does there exist a User account for this user
                MembershipUser usrInfo = Membership.GetUser(Login.UserName);
                if (usrInfo != null)
                    // Is this user locked out?
                    if (usrInfo.IsLockedOut)
                        Login.FailureText = "Your account has been locked out because of too many invalid login attempts. Please contact the administrator to have your account unlocked.";
                    else if (!usrInfo.IsApproved)
                        Login.FailureText = "Your account has not yet been approved. You cannot login until an administrator has approved your account.";
                    else
                        Login.FailureText = "Invalid UserName / Password";
                        UserCurrent = usrInfo.UserName;
                        LoginStatus = "UnSucessfull";
                        GetUserInfo();
                else
                    Login.FailureText = "Invalid UserName / Password";
            #endregion
            #region Logged In
            protected void Login_LoggedIn(object sender, EventArgs e)
                string UserName = Session["User"].ToString();           
                LoginControl.Class1.IsLoggedIn = true;
                //If User Email is [email protected] it will be invalid. Prompt the user to update the email id. 
                LoginControl.Utility hu = new LoginControl.Utility();
                DataSet dsuser = hu.getUserDetails(UserName);
                string email;
                if (dsuser.Tables[0].Rows.Count > 0)
                    email = dsuser.Tables[0].Rows[0]["Email"].ToString();
                    if (email.Equals("[email protected]"))
                        Response.Redirect("/Pages/UserUpdates.aspx", true);
                    else
            #endregion
    //-------------------------------- Authentication code----------------------------//
      private void authenticateuser()
                try
                    if (SPContext.Current.Web.CurrentUser != null)
                        using (SPSite spSite = new SPSite(SPContext.Current.Site.Url))
                            using (SPWeb spWep = spSite.OpenWeb())
                                Utility hu = new Utility();
    _userid = spWep.CurrentUser.Name;
                                DataSet ds = new DataSet();
                                ds = hu.GetPlotid(_userid);
                                if (ds.Tables[0].Rows.Count > 0)
                                    _plotid = ds.Tables[0].Rows[0]["plotid"].ToString();
                                else
                                    if (!SPContext.Current.Web.UserIsSiteAdmin && !SPContext.Current.Web.UserIsWebAdmin)
                                        if (!SPContext.Current.Web.IsCurrentUserMemberOfGroup(SPContext.Current.Web.Groups["Allottee"].ID))
                                            SPUtility.HandleAccessDenied(new Exception("You do not have access to this page"));
                    else
                    { SPUtility.HandleAccessDenied(new Exception("Please login")); }
                catch (Exception ex)
                    //  lblMessage.Text = "Error:" + ex.Message;
                    ShowMessage("Following error has occured while executing the desried event :- " + ex.Message);
    Mohan Prakash

    1. Current work flow :-In web site the user have to register themselves in the web site and enters his details along with user id, password and email id. Once user
    is registered then he will login with his user id and password. The user id is picked from login control and that set in “SPWeb.CurrentUser” as user id and system uses "Membership.ValidateUser" method to Authenticate user for login. 
    2. New Requirement: we would like to facilitate the user to login with Email id as well as user id. 
    Problem: 
    We replaced "Membership.ValidateUser" method to our own method to Authenticate user with email id/user id and password. 
    When user is login with user id and password it is working successfully but in the case of email id and password –“the email id is picked from user control and set as
    "HttpContext.Current.User.Identity.Name" but we are not getting “SPWeb.CurrentUser” and it shows null value.” 
    We are able to get user id from database using email id of user. Please help us how we can set user id in "SPContext.Current.Web.CurrentUser".
    Mohan Prakash

Maybe you are looking for

  • My story is working in dvd studio pro but how do I get the track to play with and without the story?

    Hi there, I've targetted my first button to play all and I've targetted my second button to play all: story 1. The play all option is still playing the same as the play all:story 1 option. Can someone please help me figure out what I'm missing here.

  • Problem with XLIFF file

    Hi, I exported a XLIFF file and would like to use the following translator: https://open-language-tools.dev.java.net I'm using version 1.1 RC2. When I open the .xlf file I get the following error message: "The File is not a well-formed XML Document.

  • Send pdf as attachment to web email

    If my company switched to a gmail emai account, how do I change properties in Adobe Acrobat to reflect that instead of automatically attaching to an email through Outlook?

  • How can I turn off toplink logs?

    Hi, I am using OC4J 10.3.5.0. May I know how can I turn off toplink's logs? As it is currently generating something like this in stdout: DatabaseSession(219604438)--Connection(1514883920)--TopLink, version: OracleAS TopLink - 10g (9.0.4.5) (Build 040

  • Prevent a rs232 crash when "operation completed succesfully"

    Dear all, A certain test set-up should run for long times (months) and makes good use of RS232 comunication (over USB). Data rates are not high, but frequent, to four different devices. Very occasionally the application crashes (in debug mode, runnin