ASP login control pre-populate....based on 'attributeMapUsername' inweb.config?

  • Thread starter Thread starter i_robot73
  • Start date Start date
I

i_robot73

I've got a login control that pre-populates the username using:

TextBox txtUserName = (TextBox)Login1.FindControl("UserName");
string requestor = WindowsIdentity.GetCurrent().Name;
string[] paramsLogin = requestor..Split('\\');
txtUserName.Text = paramsLogin[1].ToString();

I'm wondering if there's an easy way to read the
'attributeMapUsername' setting (if there is one) from the web.config.

IF is set to 'sAMAccountName', remove the domain info.

Trying to make this as idiot proof as possible, since it seems no one
READS the d@mn instructions printed on the screen =P
 
I've got a login control that pre-populates the username using:

     TextBox txtUserName = (TextBox)Login1.FindControl("UserName");
     string requestor = WindowsIdentity.GetCurrent().Name;
     string[] paramsLogin = requestor..Split('\\');
     txtUserName.Text = paramsLogin[1].ToString();

I'm wondering if there's an easy way to read the
'attributeMapUsername' setting (if there is one) from the web.config.

IF is set to 'sAMAccountName', remove the domain info.

Trying to make this as idiot proof as possible, since it seems no one
READS the d@mn instructions printed on the screen =P

In my web forms (Intranet only) I typically use the
Request.LogonUserIdentity.Name property. It is always in the Domain
\User format. It also contains a couple of other properties such as
IsAuthenticated IsAnonymous as well as properties containing pointers
to their Token etc.
If you are looking for an easy way to read from the web.config look at
System.Configuration.CongiurationManager.It is a static class with 2
read only properties that are collections of connectionstrings and
appsettings there are also other methods for retrieving just about any
part of the web.config you want.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top