w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How do I sign out a user authenticated on an external page with CAS, FormsAuthentication
I'm still not quite sure what was causing the phantom log out, but I was able to fix the issue I was having. I included an iframe in my application's login and logout pages, whose sources (src) are pointed at the external login and logout pages, respectively. To tell CAS where to redirect to after validating FormsAuthentication credentials, I had to append at the end of the login iframe's src url a query string that looks like ?TARGET=http%3a%2f%2fsome.url.aspx (The target url is escaped. '%3a' is url encoding for a colon (:) and '%2f' is a forward slash (/)) So, say, the external login url was https://www.externalsite.com/login and I wanted to redirect to my welcome page http://www.mysite.com/welcome.aspx after logging in, my application's login page iframe src would need to be `http

Categories : C#

Handling user entered data with weird symbols
What i can se the unicode character for this is u201D according to the code below. string = "”Test comment with weird quotes.”" p string # => "u201DTest comment with weird quotes.u201D" So string.gsub("u201D", '') should give you what you want in this case

Categories : Ruby On Rails

FormsAuthentication MVC4
You need to add filter to check that user is authenticated/Authorized or not. 1. Add following attribute public class AuthorizeWithSessionAttribute : AuthorizeAttribute { protected override bool AuthorizeCore(HttpContextBase httpContext) { if (httpContext.Session == null || httpContext.Session["XYZSession"] == null) return false; return base.AuthorizeCore(httpContext); } } 2. Set the session after SetAuthCookie() FormsAuthentication.SetAuthCookie(user.UserName, false); Session["XYZSession"] = "Set name/parameter"; 3. Set attribute before controller [AuthorizeWithSessionAttribute] public class XYZController : Controller

Categories : Asp Net Mvc

FormsAuthentication Roles without Membership
FormsAuthenticationTicket constructor (the one with the most parameters) has userData parameter which takes a string. It is here that you can add your roles, separated by some character like pipe (|) or hash. How you plan to use is up to you. What you would normally do is to register AuthenticateRequest event. So, you could create a ticket this was: private void CreateTicket() { var ticket = new FormsAuthenticationTicket( version: 1, name: UserName, issueDate: DateTime.Now, expiration: DateTime.Now.AddSeconds(httpContext.Session.Timeout), isPersistent: false, userData: String.Join("|", arrayOfRoles)); var encryptedTicket = FormsAuthentication.Encrypt(ticket); var cookie = new HttpCookie(FormsAuthenticatio

Categories : Asp Net

ASP.NET FormsAuthentication does not use State Server
I'm unclear about what you mean by "store authentication in State Server". Authentication Is never stored in session variables, and it's a poor practice to do so. Authentication is stored on the users local computer in the form of an encrypted cookie (either non-persistent or persistent), and therefore is inherently immune to any webfarm issues so long as your machinekey is specified in common on all servers. Session and FormsAuthentication are to different systems in .NET.

Categories : Asp Net

FormsAuthentication Cookie Caching
This was resolved by turning all the variables to properties with get and set to stop them from caching. Public Class userinfo Public Shared Property uNT_id As String Get If HttpContext.Current.User.Identity.IsAuthenticated Then Return HttpContext.Current.User.Identity.Name Else Return System.Environment.UserName End If End Get Set(value As String) If HttpContext.Current.User.Identity.IsAuthenticated Then value = HttpContext.Current.User.Identity.Name Else value = System.Environment.UserName End If End Set End Property Public Shared Property ui

Categories : Vb.Net

FormsAuthentication allow acces to all pages
You may be seeing this functionality because you are not specifying a location. Try this out: <location path="your folder"> <system.web> your authorization </system.web> </location> Another issue may be how you are going about granting the rights. "?" targets all unauthenticated users. If you are trying to simply grant access to all users, you would be better off with using a "*". It is also important to make note that these rules are cascading. So you can add multiple rules to fine tune your access. For example, if I wanted to grant access to a specific group of users and deny access to everyone else I would use: <authorization> <allow roles="administrators" /> <deny users="*" /> </authorization>

Categories : C#

Can I change the FormsAuthentication cookie name in asp.net dynamically?
You can't do this in code; the property FormsAuthentication.FormsCookieName is readonly. I would use the following configuration in web.config: <authentication mode="Forms"> <forms configSource="forms.config" /> </authentication> Then give each instance of the application its own forms.config: <forms name="CookieNameForThisInstance" />

Categories : Asp Net Mvc

ASP.Net MVC3 FormsAuthentication overall logged-in event
There are several events that get triggered on every request, HttpApplication.AuthorizeRequest() should work. In order to only fetch from the database for logged in users, you can check the Name property of User.Identity which only gets set once the user authenticates: if(!string.IsEmpty(User.Identity.Name)) { //make call to database }

Categories : Asp Net

PHP User Login Failure Handling
This part of code is complete and secure but you have to mention few things for more security you need to regenerate the session ID with session_regenerate_id after putting valuable data like in 'loggedin' on session. And I think it is better to put the IF part on a function and omit the else it helps your code be simpler. and Also you can remove the following lines: session_write_close(); ob_end_clean();

Categories : PHP

Handling git on a shared user account
Try git -c user.email="Karunamon <karunamon@company.com>" commit This will override the config setting when executing that command. You can then make an git alias / wrapper that inserts that value from a local env variable on execution.

Categories : GIT

handling user sign up roles with RoR?
If you are only going to have 2 roles then it is probably easiest to add a column to your users model. rails generate migration add_business_to_users business:boolean Then in the migration add a default to this column like class AddBusinessToUsers < ActiveRecord::Migration def change add_column :users, :business, :boolean, default: false end end Once you have migrated this to your database you have everything you need for 2 roles. For example you can always use user.business? #This will be true for a user that is a business and false for resident What you are effectively assuming is that every user that is not a business is a resident. If you are going to have more roles then it makes sense to have a separate roles model or use a gem like cancan.

Categories : Ruby On Rails

user based settings handling in php
I hope I got your question right but here is my idea: I assume you are using some form of database. Idea 1: Safe a set of rights with every user (e.g. boolean values "edit", "create" or something like that) Pro: High flexebility in which user is allowed to do what. Cons: Every user has his own set of rights, thus you have quite a lot of data floating around your database. Idea 2: Safe a set of groups or roles wich get different rights and you assign a group or a role to a user. Pros: Rather low amount of data. Cons: Lower flexebility if you don't want to make a group for every user wich would lead to Idea 1. I hope that helped and I hope I din't get your question wrong!

Categories : PHP

ASP.NET FormsAuthentication.CookiesSupported sometimes returns false for mobile browsers
This seems to be a problem relating to browser capability in asp.net. It uses user-agent string to identify a browser and matches it to determine capabilities. The framework lacks enough information for ios and other newer mobile based browsers. I think this has been fixed with ASP.Net v4.5. Meanwhile you can use this workaround to tell ASP.Net that every (generic) browser supports cookies: Add a special folder in your project "App_Browsers". Within this folder create a file named "generic.browser". Paste the following text in this file: <browsers> <browser refID="Mozilla"> <capabilities> <capability name="xml" value="true" /> <capability name="cookies" value="true" /> </capabilities> </browser> &l

Categories : Asp Net

Handling User Auth (via Facebook) and secure communication within an app
I don't know if you could authenticate your app with facebook module but take a look at backend as a service providers like this one: apiOmat the also offer "private beta modules" which means you can ask for features.

Categories : Android

Converting FormsAuthentication cookie to string for use in public shared variable
The following code returns the string I am trying to return Public Shared uNT_id = If(HttpContext.Current.User.Identity.IsAuthenticated, HttpContext.Current.User.Identity.Name, System.Environment.UserName) however if a user logs in and terminates the window, which SHOULD kill the cookie, the HttpContext.Current.User.Identity.Name is still equivalent to the last user to log in. The same holds true if a new user attempts to log in.

Categories : Vb.Net

Why ASPXAUTH cookie not found in the Request.Cookies[FormsAuthentication.FormsCookieName]?
we used mojoportal cms for our project, so when I set the FormsAuthentication cookie, the cms also checks for the username in their database. After adding the username in the database the problem solved. If you are using https then check the RequireSSL=true in the Forms Authentication has been used in web.config. <forms name=".mojochangeme" protection="All" timeout="20160" path="/" cookieless="UseCookies" requireSSL="true" /> I am using two database for my project and if I add the username into another database, that is mojoportal database, then it is not an efficient way for me. So I used CustomPrincipal class which will be substitute of FormsAuthentication but cookie will not be set. CustomPrincipal Class: public class CustomPrincipal:IPrincipal { public IIdenti

Categories : C#

Java server handling data - Receive and send data
Use Grizzly, Mina, or Netty. Here's Sun's sockets tutorial if you want to learn from the ground up. Grizzly and Mina use Java NIO which is confusing to a beginner. Might want to start with the tutorial. Out of the 3 frameworks I suggested, I've only used Netty for a project. I read Netty was lower level, and had more speed 6 months ago. It worked well for me.

Categories : Java

Is there a Jeff Atwood's User Friendly Exception Handling (Or Similiar) for C# / Winforms .Net 3.5+?
You could set up an unhandled exception handler, then log those exceptions out using a library like ELMAH but configurable from code, given you don't have a web.config. We use: http://nuget.org/packages/StackExchange.Exceptional/ Catching unhandled exceptions: http://mike.woelmer.com/2009/04/dealing-with-unhandled-exceptions-in-winforms/

Categories : C#

Customize events handling of an asp.net user-control depending on the calling form
Despite the fact if this is a good design you are trying to implement: you could add a property to your control like public BehaviourEnum Behaviour { get; set; } // You need to implement the enum Then you could void ComboboxCountry_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e) { if (Behaviour == BehaviourEnum.Behave1) // etc. } The pages implementing your control would need to set the Behaviour-Property accordingly. Edit: If your control needs to interact with the parent page, I would introduce an interface on the parents page. Then you could design something like this: // The page containing this control needs to implement IMasterpage public IMasterpage Masterpage { get; set; } void ComboboxCountry_SelectedIndexChanged(object sender, RadCom

Categories : C#

Socket Data Handling -for data packing (TCP)
In short: yes. TCP transfers a stream of bytes, there is no mention of messages (and their boundaries) in a TCP connection. Even if you send two bytes they can be received in two separate chunks (theoretically of course; it's quite unlikely in practice). So you should put some marks into your data stream. I'd suggest writing a "message header" before every message where the header contains at least length of the following message's body. And take care, the header itself may also be fragmented when receiving.

Categories : C#

Handling SQL data in C#
There are multiple problems here. One is that you haven't shown where sqlCommand1 or sqlConnection1 are declared or initialized. My guess is that they're both null, which is why you're getting the exception. They should be declared and initialized within the method, using using statements so they get disposed appropriately: using (var connection = new SqlConnection(...)) { connection.Open(); using (var command = new SqlComand(...)) { ... } } Then there's this problem. SELECT id,parola FROM ANGAJAT WHERE id='@user' AND parola='@pass' The fact that you're got quotes means you're looking for an ID of exactly @user - not the value of the @user parameter. You want: SELECT id,parola FROM ANGAJAT WHERE id=@user AND parola=@pass EDIT: And as noted, initialize your

Categories : C#

Handling data from server
You need to redesign your protocol. The main issue here is that you don't give the size of the message that you're sending before the message itself, and therefore you don't know how much to read from the input stream for each message. Here's an example for a really simple protocol. Each message consists of two fields: Size (unsigned int). The message itself. Then, for each message you read twice. First, you read the message size sizeof(unsigned int), then read the message itself (you now know its size). This also removes the necessity for the null separator between messages, which can possibly occur inside your message if you don't escape it correctly, and can cause serious problems.

Categories : Objective C

Ember-Data handling 401’s
Application.initializer is not the correct place to put this logic. It is synchronous and it's purpose is to do things like adding custom objects to the IOC container, etc. This code is better suited in the model hooks of ApplicationRoute. App.ApplicationRoute = Ember.Route.extend({ beforeModel: function() { return App.User.find({ filter: "authenticated" }); }, setupController: function(controller, model) { controller.set('loggedIn', true); controller.set('currentUser', model);// or some property of that model }, events: function() { error: function(err) { // error handler called in case of an error. // show the error message to user here // or transition to another route } } });

Categories : Ember Js

handling a lot of data with mysql and php in search
Yes, you should definitely put more emphasis on MySQL. Don't serialize the parts for each car into a single row of a single column. That's terribly inefficient. Instead, make yourself a parts table, with columns for the various data items that describe each part. part_id an autoincrement item. car_id which car is this a part of partnumber the part's external part number (barcode number?) etc Then, use JOIN operations. Also, why don't you use a WHERE clause in your SELECT statement, to retrieve just the car you want? Edit If you're looking for a part, you definitely want a separate parts table. Then you can do a SQL search something like this. SELECT w.id, w.model, w.specification, w.year, w.fueltype, p.partnumber FROM warehouse w JOIN parts

Categories : PHP

Handling data between multiple Forms
The answer to your problem is quite simple. NewPDF.Show(); Show() does not pause execution of the calling form. Therefore, the check underneath that that verifies the Selected property if true will never execute properly, since that check is reached and verified just as the form starts appearing. ShowDialog() does pause execution and waits for the called form to close. That aside; I would recommend one of two other ways to communicate between forms; Use a global variable. Declare a variable holding the graph's name somewhere in a public module. Call the dialog that asks the user to input a name with ShowDialog(), since that pauses execution of the calling form until the called form returns a result. if(Form.ShowDialog() == DialogResult.OK) { // Save pdf, using title in global vari

Categories : C#

JSON data handling in SQL Server
There is no native way to parse JSON in TSQL. But Phil Factor created his own implementation of paring JSON in SQL function. More about it on simple talk blog in article: Consuming JSON Strings in SQL Server Aslo Ric Vander Ark created his own function but I did not tested it. You can read more on article: A Function to Split JSON Data

Categories : Jquery

Handling variable data using << operator
Designing an API like that is not a good idea, because it is extremely error-prone. A seemingly similar idea worked fine with output streams for a simple reason: the data that you put into the stream for output is treated uniformly. Anything that you put into << as an argument becomes part of the output, apart from stream manipulators, which control how the output is to be presented. Your API is different: odd items are treated differently from the even ones. Moreover, it is a mistake to send an odd total number of operands. If for some reason you forget to put a string code on one of the lines, all values would silently become codes on the subsequent lines. Such API is very fragile, so I would strongly recommend agains it. I think an API that lets your users add items in pairs wo

Categories : C++

R: handling and plotting grouped data
At least for ggplot2 you'll want to use the reshape2 package in order to convert your data to a slightly different format. Let's imagine that you have a data.frame like this: test <- structure(list(Company = structure(1:3, .Label = c("Company1", "Company2", "Company3"), class = "factor"), X2011.1 = c(300L, 320L, 310L), X2013.1 = c(350L, 430L, 420L), X2011.2 = c(290, 305, 400), X2013.2 = c(300, 301, 305), X2011.3 = c(295, 300, 400), X2013.3 = c(290L, 400L, 410L)), .Names = c("Company", "X2011.1", "X2013.1", "X2011.2", "X2013.2", "X2011.3", "X2013.3"), class = "data.frame", row.names = c(NA, -3L)) Ignore the ugliness for now, that looks like: Company X2011.1 X2013.1 X2011.2 X2013.2 X2011.3 X2013.3 Company1 300 350 290 300 295 290 Company2 320

Categories : R

Data handling not working properly
You are using two instance of the NameSave class. You are setting the username on one instance : NameSave insert = new NameSave(); insert.putString(username); And trying to retrieve it from another : NameSave getName = new NameSave(); get = getName.name(); insert and getName are two different objects . You have to use the same instance referred by insert variable to get the name back.

Categories : Java

MVVM - Handling backing data
A singleton would generally have a static accessor. All you need is to have your viewmodels either set a property equal to the GameContainer, or individual properties to the individual memebers of the GameContainer.

Categories : C#

Handling duplicate entries in Core Data
I was wondering if Core Data has the ability to check to see if an object being added is a duplicate. No, Core Data doesn't care about that. Is there a predicate that can handle checking for duplicates? Since your objects have unique IDs that you control, do a fetch for an existing favorite with that ID. Something like NSFetchRequest *fetch = [NSFetchRequest fetchRequestWithEntityName:@"Favorite"]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"stationIdentifier == %@", stID]; [fetch setPredicate:predicate]; If you get any results, you know that a favorite with that ID already exists. And, you have a reference to that favorite in case you want to change it. Your current approach is fine and probably faster if there are only a few favorites. Doing a fetch will sc

Categories : IOS

Angular JS / data handling / overview page
If you want to persist data between actual HTML pages and not routes within a single page, you could use LocalStorage. Here is a service that will make that a little easier. Another approach would be to use cookies. You can read more about using cookies in Angular here. If you are wanting to persist the data across different routes, you will need to create a shared service. Here is an example of such an approach: <div ng-app="myApp"> <a href="#one">one</a> | <a href="#two">two</a> <div ng-view></div> <script id="one.html" type="text/ng-template"><div><h1>Template One</h1>foo = {{shared.foo}}</div></script> <script id="two.html" type="text/ng-template"><div><h1>Template Two<

Categories : Angularjs

Background fetch on iOS and handling the returned data
Make a property for NSData says fetchedData. in .h and synthesize it in .m then set this property after date fetch then call the method which is required. There are some delegate which tells you data data loading is done so at there you can set your property an from background you can call UI updating method on main thread that gives you your desired result. you can use selector like this for calling on main thread [self performSelectorOnMainThread:@selector(rollBar:) withObject:nil waitUntilDone:false];

Categories : Objective C

Handling session data using a static class
I'd use IoC container (for example Castle Windsor) for this. Declare an interface, for example, IStateManager: public interface IStateManager { T GetItem<T>(string key); SetItem<T>(string key, T value); } Then, your implementation of the Session class will change like the following: public static class Session { private static IStateManager _manager; private static IStateManager Manager { get { if (_manager == null) { IStateManager m = null; // Get instance using IoC container Interlocked.CompareExchange(ref _manager, m, null); } return _manager; } } public static string CurrentUser { get { return Manager.GetItem<string>("C

Categories : C#

R subsetting data and handling null findings
For your particular example, selecting the column to have its value set inside the bracket operator will avoid the issue: trx <- data.frame(Currency="XXX", ExchangeOriginal=30) trx[trx$Currency == "EUR", "ExchangeOriginal"] <- 1 # Does nothing (Also note that since you can use boolean expressions for subsetting, you don't need "which".) Answering your second question, the try and tryCatch functions could be used here to recover from the error, but it seems better to avoid the error in the first place if possible: try(trx[trx$Currency == "EUR", ]$ExchangeOriginal <- 1)

Categories : R

Handling file size for SQL FILESTREAM data
I believe the article is suggesting not to use DATALENGTH() if it can be avoided. Storing the file size in a separate column is a suitable alternative, along with other metadata about the files (content type, extension, timestamp, etc). This will allow you to query/filter file details more efficiently. If the file contents are not expected to change, simply updating a filesize column while persisting the filestream data is simplest. If the contents are expected to change, you need to remember to update the file size as well. This can also be accomplished in Sql with a persisted computed column

Categories : Dotnet

Handling admin rights in mixed user/admin windows app
I don't know if it's the best way (no-one answered) but I did that now :) The bootstrapper has just requireAdministrator in the Manifest and does a ShellExecute to the main executeable with switch "/Activate" ...

Categories : Windows

Handling webServices call and cached data in Fragments
1.first you need to create data structure for holding data for fragment check in data structure that data is available for selected fragement and it is time for refresh data if yes then call load data(web service to load data) into fragment else load data from data structure and show in fragment.

Categories : Android

Handling large amount of data and processes in multiprocessing
Try just using a global variable to store your common arrays and allow the forking/subprocess behavior of inheriting parent process data to do your work for you (although note this may not work if your arrays are REALLY REALLY big). This might get around the issue of pickling large amounts of data via the Process constructor.

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.