Hi, I would like to set up Windows authentication for the portal because it will run on a intranet only. I follow the instructions and comment out the Forms Authentication section of the Web.Config file and uncomment the Windows Authentication section. OK so
far...Now I go to the site and get the standard default page. Now the big question - How to I log in as Admin? Second question - How to I manage other users based on their domain ID to add them to certain groups? I want the authentication to happen automatically.
Thanks.
You have to add manualy to table "Users" your User where Email must be "Domain\User" then add to table "UserRoles" That UserID whith RoleID as "0" to make him Admin
I have this working fine but you can't edit the users or add users via the Admin interface once you have access to it. If you look at the address bar the error is clearly visible. I just don't know how to fix it. Maybe someone could give me some pointers. Example:
/Admin/ManageUsers.aspx?userId=27&username=DOMAIN/bubba&tabindex=7&tabid=6 You enter the username in the form as DOMAIN\bubba but when you click save changes it to DOMAIN/bubba which, of course, doesn't exist. It successfully adds the user to the database
but because the MangeUsers page converts the backslash to a forward slash every time you can't edit the user in the future. While the error page is on the screen, saying no data is present, you can edit the address bar and change the slash to a backslash and
hit enter and it loads the page the right way....until you try saving again. Any fixes for this yet??????
Response.Redirect in ASP.NET seems to automatically convert any backslashes (\) to forward slashes (/) in a URL. This occurs on the Click event of the updateUserBtn on line 154 of manageUsers.aspx.vb: Response.Redirect("~/Admin/ManageUsers.aspx?userId=" & userId
& "&username=" & Email.Text & "&tabindex=" & tabIndex & "&tabid=" & tabId),) The userId will alway get changed to an invalid one which doesn't exist in the database because of the slash replacement A quick fix to this problem is to manipulate the slashes on
the next bind when reading values in from teh query string. On line 196 of manageUsers.aspx.vb add a simple replace to return any forward slashes to their previous states: Dim dr As SqlDataReader = users.GetSingleUser(userName) Dim dr As SqlDataReader = users.GetSingleUser(Replace(userName,
"/", "\")) I'm pretty sure this wont effect any other code as long as your not doing something strange like including forward slashes to your windows authenticated usernames!
Your actually better off making the above edit to line 56 as soon as the parameter is read in so that the role assignment works too. line 56 (PortalVBVS): userName = CStr(Replace(Request.Params("username"), "/", "\"))
I just changed line 36-38 of ManageUsers.aspx from: If Not (Request.Params("username") Is Nothing) Then userName = CStr(Request.Params("username")) End If to If Not (Request.Params("username") Is Nothing) Then userName = CStr(Replace(Request.Params("username"),
"/", "\")) End If It still shows up as a forward slash in the address bar but the page converts it as it loads in the background. L8R
I was able to figure out the change myself. For those interested, I changed line 48 of ManageUsers.aspx.cs from this: userName = (String)Request.Params["username"]; to this: userName = ((String)Request.Params["username"]).Replace("/","\\"); It seems to be working
just fine, now.
I seem to be having another type of problem with the "\" in the user name. For some reason the back slash causes the following error: Invalid attempt to read when no data is present. Description: An unhandled exception occurred during the execution of the current
web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: Invalid attempt to read when no data is present. Source Error: An unhandled exception
was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [InvalidOperationException: Invalid attempt to read when no
data is present.] System.Data.SqlClient.SqlDataReader.PrepareRecord(Int32 i) +184 System.Data.SqlClient.SqlDataReader.GetValue(Int32 i) +27 System.Data.SqlClient.SqlDataReader.get_Item(String name) +20 ASPNetPortal.ManageUsers.BindData() +72 ASPNetPortal.ManageUsers.Page_Load(Object
sender, EventArgs e) +854 System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +29 System.Web.UI.Page.ProcessRequestMain() +724 -------------------------------------------------------------------------------- Version Information:
Microsoft .NET Framework Version:1.0.3705.0; ASP.NET Version:1.0.3705.0 Has anyone seen this? I have made the change noted above regarding replace but it didn't make any difference. I searched the forum pretty well and havn't found anything. Thanks, Eudell
Hello, have you figured out why you can't see the Admin? I've got the same problem. I can't even open UserRoles table to add my name as admin. Did you find out how to fix our problem?
I extended the Portal code and now register new users in the Portal user and userole table based on NT Group membership. Also other user info is retrieved from the Active Directory. I have no problems with the problems described above...
Go to the userRoles Table and insert a new row. In the userid field put the user id of your Windows user and in the roles field put 0. refresh the page.
Hello, One problem with windows authentication is that you have a combination of DOMAINNAME\USERNAME that needs to be split as you access your system. You definately can intergrate with AD for in house users. But, I would keep the methods the same for extracting
the user name from WINDOWS or FORMS authentication. I'm currently toying around with the different functions for both types of authentication to help determine best practice.
//This information is if you're using windows authentication and //threads are being used to help control the instance. AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); WindowsPrincipal MyPrincipalA = (WindowsPrincipal) Thread.CurrentPrincipal;
//Get the current identity and put it into an identity object. WindowsIdentity MyIdentity = WindowsIdentity.GetCurrent(); //Put the previous identity into a principal object. WindowsPrincipal MyPrincipal = new WindowsPrincipal(MyIdentity); //Principal values.
string Name = MyPrincipal.Identity.Name; string Type = MyPrincipal.Identity.AuthenticationType; string Auth = MyPrincipal.Identity.IsAuthenticated.ToString(); //Identity values. string IdentName = MyIdentity.Name; string IdentType = MyIdentity.AuthenticationType;
string IdentIsAuth = MyIdentity.IsAuthenticated.ToString(); string ISAnon = MyIdentity.IsAnonymous.ToString(); string IsG = MyIdentity.IsGuest.ToString(); string IsSys = MyIdentity.IsSystem.ToString(); string Token = MyIdentity.Token.ToString();
The other thing you will need to do is to split the DOMAINNAME\USERNAME fields so that no matter what method of authenticaiton that you use you're applicaiton will still work. I've added this to my getUserRolls function right before the authentication.ticket
is written out. HttpContext Context = HttpContext.Current; string[] Roles = null; string formattedUserRoles; // Values indicating that maybe windows authentication was used and you // have a domain and user name to split. 10-01-2002 jlk // DOMAINNAME\DOMAINUSER
string DomainName = ""; string DomainUser = ""; // Is the request authenticated? if (!Context.Request.IsAuthenticated) return; // Get the roles this user is in if ((Context.Request.Cookies[rolesCookie] == null) || (Context.Request.Cookies[rolesCookie].Value
== "")) { //This section splits out the DOMAIN name from a user if that user is using windows //authentication: StringBuilder sb = new StringBuilder(Context.User.Identity.Name); sb.Replace("\\","-"); string[] array = sb.ToString().Split("-".ToCharArray());
if (array.Length == 1) { Roles = UserRoles.GetUserRoles(Context.User.Identity.Name); } else { DomainName = array[0]; DomainUser = array[1]; if (DomainUser != null) { Roles = UserRoles.GetUserRoles(DomainUser); } else { Roles = UserRoles.GetUserRoles(Context.User.Identity.Name);
} } formattedUserRoles = String.Join(";", Roles); Let me know if this works for you! Thank you, Joseph
ANOTHER SOLUTION Instead of changing the portal code modify the SQL stored procedures GetSingleUser and AddUser. Replace the WHERE Statement in GetSingleUser with 'WHERE Email = REPLACE(@EMail,'/','\') Replace the VALUE text in AddUser with 'REPLACE(@EMAIL,'/','\'),
No sure if you really need to change the AddUser procedure, but it doen't hurt just in case.
The reason I changed my forum code was so that I could incorporate the information into the IBS data at the same time. I wanted to keep one base of code for looking at users. I've also incorporated the Store into one central code base all called from within
the framework. I have changed some things around with all modules and functions so that it works for me. I'm planning on releasing the code when I have tested it and have had others look at the structure. I have the modules up (today and not fully tested)
at http://www.stat-sphere.com and should have some of the work down by end of week. I've been out of town and will get to the code and samples ASAP.
I avoided this problem all together by URL encoding the query string that is passed into the edit users page. Then I decoded on the other side. I have never since had a problem with the slashes changing direction, or receiving the "no data is present" error
that you did, above. Keith
I made the change to the stored procedures which solved the error problem, but now the roles that a user is in don't show up when I edit the username. Now I have to go into the role and see who is a member before I could see the roles in the usernames properties.
Does anyone know how to fix this.
None
0 Points
1 Post
Windows Authentication and IBuySpy Portal problems
Jul 05, 2002 05:42 PM|howardsilver|LINK
None
0 Points
6 Posts
Re: Windows Authentication and IBuySpy Portal problems
Jul 17, 2002 05:17 AM|ac-pt|LINK
None
0 Points
2 Posts
Re: Windows Authentication and IBuySpy Portal problems
Jul 31, 2002 02:50 PM|gbenjamin|LINK
None
0 Points
2 Posts
Re: Windows Authentication and IBuySpy Portal problems
Aug 18, 2002 11:41 PM|bermo|LINK
None
0 Points
2 Posts
Re: Windows Authentication and IBuySpy Portal problems
Aug 19, 2002 12:02 AM|bermo|LINK
None
0 Points
2 Posts
Re: Windows Authentication and IBuySpy Portal problems
Aug 19, 2002 04:22 PM|gbenjamin|LINK
None
0 Points
2 Posts
Re: Windows Authentication and IBuySpy Portal problems
Aug 24, 2002 07:42 AM|sup|LINK
None
0 Points
2 Posts
Re: Windows Authentication and IBuySpy Portal problems
Oct 02, 2002 04:04 PM|RayD|LINK
None
0 Points
2 Posts
Re: Windows Authentication and IBuySpy Portal problems
Oct 02, 2002 05:53 PM|RayD|LINK
None
0 Points
1 Post
Re: Windows Authentication and IBuySpy Portal problems
Oct 03, 2002 09:01 AM|Eudell|LINK
None
0 Points
1 Post
Re: Windows Authentication and IBuySpy Portal problems
Oct 09, 2002 01:57 PM|tshmat|LINK
None
0 Points
1 Post
Re: Windows Authentication and IBuySpy Portal problems
Oct 10, 2002 06:19 AM|EricSoonius|LINK
None
0 Points
2 Posts
Re: Windows Authentication and IBuySpy Portal problems
Oct 30, 2002 06:21 PM|honestJrabbit|LINK
None
0 Points
6 Posts
Re: Windows Authentication and IBuySpy Portal problems
Oct 31, 2002 03:38 AM|webcontrol|LINK
None
0 Points
2 Posts
Re: Windows Authentication and IBuySpy Portal problems
Oct 31, 2002 08:57 PM|SimpleTin|LINK
//This information is if you're using windows authentication and //threads are being used to help control the instance. AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); WindowsPrincipal MyPrincipalA = (WindowsPrincipal) Thread.CurrentPrincipal; //Get the current identity and put it into an identity object. WindowsIdentity MyIdentity = WindowsIdentity.GetCurrent(); //Put the previous identity into a principal object. WindowsPrincipal MyPrincipal = new WindowsPrincipal(MyIdentity); //Principal values. string Name = MyPrincipal.Identity.Name; string Type = MyPrincipal.Identity.AuthenticationType; string Auth = MyPrincipal.Identity.IsAuthenticated.ToString(); //Identity values. string IdentName = MyIdentity.Name; string IdentType = MyIdentity.AuthenticationType; string IdentIsAuth = MyIdentity.IsAuthenticated.ToString(); string ISAnon = MyIdentity.IsAnonymous.ToString(); string IsG = MyIdentity.IsGuest.ToString(); string IsSys = MyIdentity.IsSystem.ToString(); string Token = MyIdentity.Token.ToString();
The other thing you will need to do is to split the DOMAINNAME\USERNAME fields so that no matter what method of authenticaiton that you use you're applicaiton will still work. I've added this to my getUserRolls function right before the authentication.ticket is written out.HttpContext Context = HttpContext.Current; string[] Roles = null; string formattedUserRoles; // Values indicating that maybe windows authentication was used and you // have a domain and user name to split. 10-01-2002 jlk // DOMAINNAME\DOMAINUSER string DomainName = ""; string DomainUser = ""; // Is the request authenticated? if (!Context.Request.IsAuthenticated) return; // Get the roles this user is in if ((Context.Request.Cookies[rolesCookie] == null) || (Context.Request.Cookies[rolesCookie].Value == "")) { //This section splits out the DOMAIN name from a user if that user is using windows //authentication: StringBuilder sb = new StringBuilder(Context.User.Identity.Name); sb.Replace("\\","-"); string[] array = sb.ToString().Split("-".ToCharArray()); if (array.Length == 1) { Roles = UserRoles.GetUserRoles(Context.User.Identity.Name); } else { DomainName = array[0]; DomainUser = array[1]; if (DomainUser != null) { Roles = UserRoles.GetUserRoles(DomainUser); } else { Roles = UserRoles.GetUserRoles(Context.User.Identity.Name); } } formattedUserRoles = String.Join(";", Roles);
Let me know if this works for you! Thank you, JosephThank you,
Joseph
None
0 Points
1 Post
Re: Windows Authentication and IBuySpy Portal problems
Nov 07, 2002 12:41 PM|RXLX|LINK
None
0 Points
4 Posts
Re: Windows Authentication and IBuySpy Portal problems
Nov 18, 2002 01:29 PM|bspolarich|LINK
None
0 Points
4 Posts
Re: Windows Authentication and IBuySpy Portal problems
Nov 18, 2002 01:31 PM|bspolarich|LINK
None
0 Points
2 Posts
Re: Windows Authentication and IBuySpy Portal problems
Nov 24, 2002 08:24 PM|SimpleTin|LINK
Thank you,
Joseph
None
0 Points
1 Post
Re: Windows Authentication and IBuySpy Portal problems
Nov 26, 2002 05:48 PM|kmycek|LINK
None
0 Points
6 Posts
Re: Windows Authentication and IBuySpy Portal problems
Jan 16, 2003 03:00 PM|nreagles|LINK
None
0 Points
1 Post
Re: Windows Authentication and IBuySpy Portal problems
Mar 05, 2003 11:02 PM|aleck|LINK
None
0 Points
3 Posts
Re: Windows Authentication and IBuySpy Portal problems
Oct 29, 2003 02:56 PM|Homer J Simpson|LINK