CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.security Tags:
Item Type: NewsGroup Date Entered: 10/14/2006 3:58:56 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 3 Views: 31 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
4 Items, 1 Pages 1 |< << Go >> >|
mtsonic
Asp.Net User
Passing User.Identy.Name from VB to C#10/14/2006 3:58:56 PM

0/0

Short and simple...  When I pass User.Identity.Name from a VB code behind aspx page to a C# custom provider the value changes from <domain>\<userName> to <domain>\\<userName>.  Note the double \\.  Why is this and how do I handle it? 

I tried using a replace function but when I type a single \ in the string to use as the substitution, C# thinks I want a new line and says 'Newline in constant' error.

I looked at the ProviderToolkitSampleProviders.  Particularly the SQLRoleProvider.GetRolesForUser(string username).  They don't handle any problems with the username so I'm thinking that I'm doing something wrong or they handle it in the base class somehow.  Any ideas?

Fredrik N
Asp.Net User
Re: Passing User.Identy.Name from VB to C#10/14/2006 4:06:29 PM

0/0

You don't need to be worry about the '\\', you can't in C# write one single '\'. It's because '\' is an escape sequence and in C# '\\' is handle like '\'.


/Fredrik Norm?n NSQUARED2
Microsoft MVP, MCSD, MCAD, MCT

Cornerstone

My Blog, ASP.Net 2.0 etc
mtsonic
Asp.Net User
Re: Passing User.Identy.Name from VB to C#10/14/2006 5:42:05 PM

0/0

With further debugging I found the my stored procedure is bailing before the userId lookup when I try to get the applicationId from the applicationName.  Below is the code used to get the applicationName.  If returns the virtual path of '/<application name>'.  Note the inclusion of the forward slash.  This does not equal <applicationName> which is what's in the database.  This code also came from the toolkit in the SecUtil.cs  I can augment my sql in the stored procedure but this seems like a bandaid when the aspnet database doesn't do this.  Any suggestions?

internal static string GetDefaultAppName()

        {

            try

            {

                string appName = HostingEnvironment.ApplicationVirtualPath;

 

                if (String.IsNullOrEmpty(appName))

                {

 

                    appName = System.Diagnostics.Process.GetCurrentProcess().

                                     MainModule.ModuleName;

 

                    int indexOfDot = appName.IndexOf('.');

                    if (indexOfDot != -1)

                    {

                        appName = appName.Remove(indexOfDot);

                    }

                }

 

                if (String.IsNullOrEmpty(appName))

                {

                    return "/";

                }

                else

                {

                    return appName;

                }

            }

            catch

            {

                return "/";

            }

        }

 

mtsonic
Asp.Net User
Re: Passing User.Identy.Name from VB to C#10/14/2006 6:01:42 PM

0/0

Or I could just change the application name to /<application name> which I think is the correct answer.  You were then correct about the userName.  It worked after I changed the application name.  Also in the web.config file.
4 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Network Programming in .NET: With C# and Visual Basic .NET Authors: Fiach Reid, Pages: 541, Published: 2004
Pro ASP.NET 2.0 in VB 2005: special edition. Authors: Laurence Moroney, Matthew MacDonald, Pages: 1360, Published: 2006
MCAD/MCSD Training Guide (70-310): Developing XML Web Services and Server Components with Visual Basic. Net and the . Net Framework Authors: Mike Gunderloy, Ed Tittel, Pages: 1024, Published: 2003
Programming ASP.NET: Building Web Applications and Services Using C and VB.NET. Authors: Jesse Liberty, Dan Hurwitz, Pages: 988, Published: 2003
Visual C# 2005: How to Program Authors: Harvey M. Deitel, Paul J. Deitel, Pages: 1591, Published: 2006
Application Development Using Visual Basic and .NET Authors: Robert J. Oberg, Peter Thorsteinson, Dana L. Wyatt, Pages: 830, Published: 2002
Professional ASP.NET 2.0 Authors: Bill Evjen, Scott Hanselman, Farhan Muhammad, Srinivasa Sivakumar, Devin Rader, Pages: 1253, Published: 2005
Microsoft Visual C# 2005 Unleashed Authors: Kevin Hoffman, Pages: 692, Published: 2006

Web:
Serious issue with HttpContext.Current.User.Identity.Name - .NET ASP User.Identity.Name. Get answers to your questions in our . ... usually a coding error where you store the user info in a vb module or c# ...
.NET csharp Cannot Pass Session Variables from C# to VB-ASP? Oct 14, 2008 ... Identity.Name. Using the user login name, I can re-create the session variables that I cannot pass from a C# module to a VB-ASP module. ...
ASP.NET - Accessing User Identity In Class Library | DreamInCode.net User.Identity.Name, but I think the Session object is probably your ... will generally pass the users domain Id (in one fashion or another). ...
PassportIdentity.LoginUser Method (String, Int32, Boolean, String ... Pass null Nothing nullptr a null reference (Nothing in Visual Basic) to indicate ... User.Identity) Is PassportIdentity Then ' If this page isn't set to use ...
Trying to pass a variable in a select statement : VB.Net, IE, NA Value = User.Identity.Name End Sub I also have a clsBasePage.vb with this: Imports Microsoft. ... OLEDB.4.0;Data Source=""C:\Visual Studio ...
Veeresh D. - Experienced Programmer in VB, C, C++, Java/J2EE, .Net ... p>To work closely with customer and understand his requirement, ... And many Flash movies, C & VB applications and Web programs. ...
CodeGuru: Managed C++: Determining User Security Roles Calling this method dictates how principal and identity objects should be ... When constructing this type, you must pass both the name of the user (the ...
Vinz d' Code Monkey - Friday, September 12, 2008 Entries Passing Multiple Querystring values with Response.Redirect method .... User. Identity.Name); } } VB.NET Private Sub getData(ByVal user As String) ...
User.Identity.Name and annoymous access account - .NET ASP Response.Write("
" & Page.User.Identity.Name & "
") .... If you enable Integrated Windows Security you can pass on an authenticated ...
TheMSsForum.com >> Asp >> Passing User Input - The Microsoft ... "name starts with wrong token ..." <%@ Page Language="VB" debug . ... Thanks for your help. C. Tag: Passing User Input Tag: 427712 ...




Search This Site:










two login controls

solpart menu

why asp.net can use many programming language in one software

what is the "does not match the assembly reference" error ?

hyperlink column in datagrid

error in getportalsettings - i think

phase one is done!!!!

how to set imageurl to a file another drive in onclick event?

array question

use response.redirect according message

enabling carriage returns in label

how do i disable the user from editing there profile? but still show there name??

user registration problem

translating in asp.net

treeview menu

no idea and feel really stupid!

trisect developments internal messages module released

asp.net language reference

how to differentiate between disposable and non-disposable object?

dynamically generated customvalidator

where can i sell my control?

how to include the correct htm file in aspx depending on querystring?

how to create a "loading" page content page

could not find installable isam.

ie web controls

is asp right for me?

arraylist related question

problems with community/forums on dnn.com

unable to update or delete a doc category

log on custom membership provider ( override validate user)

 
All Times Are GMT