.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

Reading user credentials in XSL?

Posted By:      Posted Date: September 23, 2010    Points: 0   Category :ASP.Net


I would like to have only a specific number of users allowing to see a specific part of a XML document. Therefore I want to use <xsl:if> like <xsl:if user="Fritz">.

I has to be analyzed who has requested the specific website by using the Negotiate-credentials sent in the header of the HTTP-request. Depending on this, the specific user might or might not see parts of the XML document.

I do not want to use .NET. I just want to focus on XML/XSL.

I also would like to keep my fingers away of writing coder, which would enable entering credentials in a form.

How to do (if possible)?

View Complete Post

More Related Resource Links

Getting user's credentials, who modified a folder



I have made a windows form application which uses a FileSystemWatcher control to watch after changes made in a specific folder.

Because I am talking about a shared folder in an organization, in case a change in a folder is made, I would like to know which user did it.

Is there any possibility to get user's username (the user that made a change in a folder)?


Could not create Windows user token from the credentials specified

Hi All,

I have developed a web service and installed in a server suucess fully, its working fine there.

I tried to work in another server, But I had some error there in the new server.

I trying to access a network folder, Its accessible for the user which I have mentioned in the web config, But I'm having error.

in the web config
<identity impersonate="true" userName="UserName" password="password"/>

If you have any idea tel me


Web Service credentials after 'Sign in as different user'


I am connecting to exchange using the exchange web service from within Sharepoint Server enterprise edition (2010) code running in an application page





service.Url = 


service.Credentials = System.Net.

Executing SharePoint console application without sharing user credentials


I have a console application, which uses SharePoint object model to do some business operation, therefore it has been deployed on SharePoint server. Without sharing username/pwd, earlier we allow several users to access this console application by providing remote desktop file (.rdp) file. This .rdp file (ver5.1) contains username and encrypted password. With recent version 6.0 of .rdp, it still prompts for password. You may argue that it is due to security constraint.

What is the best approach to allow more users to run this console application without sharing user credentials, without modifying the console application.

Thanks in advance


J Justin


how to add configured credentials user to a specific group


hello guys 

i'm wondering is there a way that i can add my configuration User to a specific role ? 

so i have this in my web.config file 

<forms loginUrl="/Account/Login.aspx">
        <credentials passwordFormat="Clear">
          <user name="Admin@Egycation.com" password="password"/>

<forms loginUrl="/Account/Login.aspx">
        <credentials passwordFormat="Clear">
          <user name="Admin@admin.com&qu

Which method is better to transfer user to there home page after taking there credentials ?



i am developing a login page.After matching there given and actual credentials i have to show there own private page.So which method should i use now.Which is better one ?

Server.Transfer of Response.Redirect ?

How can i access login page's data in the user's home page if i use Server.Transer method without using Session variable ? 

Create SPUser object using user credentials on claims based site.



I would like to create SPSite object and pass user token as an argument to make sure all operations are executed with SharePoint security trimming. Inside SPSite I am reading some file content using File.OpenBinaryStream() method.

I am not sure if there is a way to create SPUser using user credentials. I am able to get SPUser by getting it from SPWeb.AllUsers collection using user login name. However it doesn't work for claims based sites as login name for these users looks like i:0#.w|domain\username. 

Am I allowed to user code like this:

SPUser user = web.AllUsers["i:0#.w|domain\username"];

to get SPUser object? I know that 'w' from 'i:0#.w' string means that it is Windows user. What do other symbols mean? Is there any method which can generate login name from user credentials so I may use it to get SPUser from AllUsers collection?

Possibly there are some other ways to execute code for SPSite under some SharePoint user privileges?

P.S. All my code is running out of SharePoint context. I have tried to user windows impersonation but got Access Denied error.

Thanks beforehand for any help,


How to get Clients Machine User credentials Username and Domain


I am trying to retrieve the loged in userName and Domain of the Clients machine. 

 string IP = (string)Request.ServerVariables["REMOTE_ADDR"];

 string IP = (string)Request.ServerVariables["REMOTE_ADDR"];

   Able to retrieve the Clients Machine IP but need to get the Remote Computer User details.


Prompting for User Credentials


I have a 2 web applications configured. One web application is configured for an Intranet and the other is configured for a MySite. These web applications are accessed internally and externally. With the internal applications I'm using integrated windows authentication and with the external applications I'm using basic authentication.

Everything works great except when I access the application externally. I obviously have to authenticate to 2 applications, the Intranet application and MySite application. The issue is when I initially access a page on the Intranet that has user profile pictures from the MySite on it. If there are 6 profile images on the page then I'm asked to authenticate 6 times to the MySite web application. If there is 1 profile image then I only have to authenticate once. Once I leave that page then I don't have to authenticate again.

Why do I have to authenticate for each profile image? Why can't I just authenticate authenticate to the MySite once?

How to check (login Credentials) user name and password to access sharepoint server 2007 programmati

my issue is...

while user entered his/her Username:xyz
i need to check programmatically either username & password exists ot not in sharepoint server 2007 from windows form application.

and i know how to check username,but i don't know how to check password.

you can check username in below ways..

 SPSite SharepointSiteObj = new SPSite(SiteUrl);
 SPWeb SharepointWebObj = SharepointSiteObj.OpenWeb("/");

 SPUserToken token=SharepointWebObj.AllUsers[userName]

from this i can get user name..




Trying to read User credentials from Active Directory.....



single farm, wss 3.p sp2

webapp1 :- AD authenticated site (just one site collection/site in web-app). AppPool account is myServer\webApp1AppPool

webapp2 : It has one site collection/site and it is Forms-authenticated. AppPool account is myServer\WebApp2AppPool

Now within webapp2 I have a simple ASPX page that accepts user LoginID and on submit in the form, I want to read the USERLOGINID from web-app1. I am getting errors like "access denied" and it is running with SPSecurity.  Apart from checking within sharepoint user collection list (in webapp1) I also check within Active Directory using DirectoryServices.

I am thinking that the myServer\WebApp2AppPool needs to be defined somewhere within webapp1. Is it true?

I also tried SPSecurity by passing user token. For some reason the AppPoolAccount of web-app1 & web-app2 has to be different.

Please suggest.

Extracting user credentials from a service implementation


I am trying to extract the login name from a web service that was authenticated using a custom username validator. It validates ok, but I am unable to extract this info within the service implementation.

So far, I have tried the following:

- return WebOperationContext.Current.IncomingRequest.Headers[HttpRequestHeader.Authorization];
- return OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name;
- return ServiceSecurityContext.Current.WindowsIdentity.Name;
- return Thread.CurrentPrincipal.Identity.Name;

The first works fine if the service is using REST, but returns an empty string with SOAP, so I am thinking the authorization credentials are in the SOAP body rather than the HTTP header in that instance.  (The WCF service supports both REST and SOAP, so I will need a solution that will work with either).

The latter three attempts throw a null reference exception.


Get Current User Credentials



My Sharepoint and CRM are on different systems but in same domain.

In my webpart i want to pass the credntials of current user logged to sharepoint to my CRM webservice to get some information.

i tried using System.Net.CredentialsCache.DefaultCredntials &System.Net.CredentialsCache.DefaultNetworkCredntials,but its raising 401 Unauthorised error.

How can i get the currentuser credentials

Thx in advance

Using SqlClient to verify user credentials


 Hey everybody,

I am building a web application that is limited to one database, thus I cannot use the handy ASP.NET config tool. I am attempting to use SqlClient to authenticate users from a user table I added to my database. Here is the code I have thus far:

Dim sqlCommand As SqlCommand = New SqlCommand
        Dim sqlConnect As SqlConnection = New SqlConnection
        Dim sqlReader As SqlDataReader
        sqlConnect.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\CLIENT_PAYMENT.mdf;Integrated Security=True;User Instance=True"
        sqlCommand.CommandText = "SELECT * FROM USER WHERE UserName=@UserName AND Password=@Password"
        sqlCommand.Parameters.AddWithValue("@UserName", strUser)
        sqlCommand.Parameters.AddWithValue("@Password", strPass)
        sqlCommand.Connection = sqlConnect
        sqlReader = sqlCommand.ExecuteReader
        If sqlReader.HasRows Then
            Label1.Visible = True
        End If

MS SQL Server: Disconnect Users From Database - Kill User Session

If you ever wanted to restore your database from a SQL backup file (.bak), but there are still users connected to your database, the backup operation will fail causing the error: Exclusive access could not be obtained because the database is in use.

Choosing Between a User Control or Web Part for SharePoint

SharePoint will only display Web Parts on a page. However, there are publicly available shims that allow you to write user controls and have them be displayed as a Web Part. From SharePoint's point of view, the shim is a Web Part. From the point of view of the user control, the shim is simply a control in .NET that is including the user control

Creating Sites/Lists/List Items under Current User Context in SharePoint By Using SPUserToken

Usually we do this by performing the action under RunWithElevatedPrivileges method and updating the listitem using SPListItem.SystemUpdate() method (see here). but this approach has its own flaws like (RunWithElevatedPrivileges will run under system account, we cannot use SystemUpdate for SPSite,SPWeb,SPList, since it runs under system we will "CreatedBy" by as SystemAccount).
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend