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

Post New Web Links

authorization programatically

Posted By:      Posted Date: October 11, 2010    Points: 0   Category :ASP.Net

I posted this to this site but my post seemed to be gone.

I can't find a solution yet for this.

I'd like to use 'authorization' in location programatically on the fly. I saw a sample which shows how to do it. It doesn't use updatding the contents of web.config etc.

How can it be done?





View Complete Post

More Related Resource Links

URL Authorization



I have 2 tables with foreign key and other requrired things to get the use data from the logged in user name.

When i visit the page that should shows the logged in user name information, I get the error of return nothing nullexception etc...

I did set the url authorization on this page and now getting (unauthorized access)

I used the login page with login control and from its propreties i did made a destination page is the (information.aspx) it is the page i want to show the user data and did the url authorization on it and it should be permitted for that specific logged in user, but even when i logged in, i still getting the (aunothrized access). 

How can i let this page knows that i am already logged in and accept me as a logged user and same as the one i gave the permit to it in the web.config?


How to write SQL Datasource programatically in VB


Can someone pls help me to rewrite this programatically!


<asp:SqlDataSource ID="DS" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                SelectCommand="SELECT * FROM [Products] WHERE ([ProductID] = @QSID)">
                    <asp:QueryStringParameter DefaultValue="" Name="QSID" QueryStringField="ID"
                        Type="Int32" />


Thank You in advance!


Claims-Based Apps: Claims-Based Authorization with WIF


Over the past few years, federated security models and claims-based access control have become increasingly popular. Platform tools in this area have also come a long way. Windows Identity Foundation (WIF) is a rich identity model framework designed for building claims-based applications and services and for supporting active and passive federated security scenarios.

Michele Leroux Bustamante

MSDN Magazine November 2009

Service Station: Authorization In WCF-Based Services


Windows Communication Foundation (WCF) provides an easy role-based system and a more powerful and complex claims-based API for implementing authorization in services.

Dominick Baier and Christian Weyer

MSDN Magazine October 2008

Authorize It: Use Role-Based Security in Your Middle Tier .NET Apps with Authorization Manager


Authorization Manager in Windows Server 2003 represents a significant improvement in the administration of role-based security, making it more scalable, flexible, and easier to implement. Using Authorization Manager, you can define roles and the tasks those roles can perform. You can nest roles to inherit characteristics from other roles, and you can define application groups. In addition, Authorization Manager lets you use scripts to modify permissions dynamically, and it allows you to wrap your security logic in a security policy that can be stored in Active Directory. Authorization Manager also includes an easy-to-use API for running access checks. The author discusses all of these topics and demonstrates them with a working sample.

Keith Brown

MSDN Magazine November 2003

How in web.config work in MVC



I would like to secure any URL below the http://MyServer/Admins and limit it to a specific role.

In webforms it was straight forward. I just put a child web.config in the /Admin/ folder and add <authorization>  <allow roles> tags to it.

How would be the equivalent technique in MVC?

Thank you,


adding programatically FilteredTextBoxExtender


 Hello, I have a problem with adding programatically FilteredTextBoxExtender (i put the code below).

The problem is that nothing is outputed when page is renedered although TextBox and FilteredTextBoxExtender are added to container (table cell controls property in my case).


TextBox tbDictionaryEntryTextBox = new TextBox();
tbDictionaryEntryTextBox.ID = "tbDictionaryEntry_" + controlNameSuffix;
tbDictionaryEntryTextBox.Width = Unit.Pixel(controlWidth);
if (isNumeric) {
      ftei = new FilteredTextBoxExtender();
      ftei.ID = "fteDictionaryEntry_" + controlNameSuffix;
      ftei.TargetControlID = tbDictionaryEntryTextBox.ID;
      ftei.FilterType = FilterTypes.Numbers;
      ftei.Enabled = true;         
Best Regards,


Create databound nested ajax toolkit accordion programatically(In code Behind)


Can anyone guide me in the right direction or give an example of How I would accomplish this?


I have  this so far but kind of stuck on how to do it programtically if I'm using header and content templates 

I have a xmldatasource.. In a nutshell at what point in my code do I need to create a new accordion? does it need to be

in the item_databound handler?


Imports Microsoft.VisualBasic

Public Class AccordionTemplate
    Implements System.Web.UI.ITemplate

    Dim templateType As String

    Sub New(ByVal type As String)
        templateType = type
    End Sub

    Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) _
          Implements System.Web.UI.ITemplate.InstantiateIn

        Dim ph As New PlaceHolder()

        Select Case (templateType)
            Case "Header"
                Dim myLabel As Label = New Label()
                myLabel.Text = "Test"
            Case "Content"
                ph.Controls.Add(New LiteralControl("<p>hello</p>"))
        End Select
    End Sub

End Class



Partial Class Accordion
    Inherits System.Web.UI.Page


Terminating a SharePoint Workflow Programatically



I have a custome workflow coded in VS 2005 and deployed in to GAC and associated to a List in the SharePoint Portel through MS SharePoint Designer.


When an Exception happened in the code, the worklow instance' Status is shown as "Error Occured" and get suspended. since this workflow instance is "hung up" at this list item another instance of the workflow can't run. To run another instance you have to go into the SP Portal --> List and click on the "Error Occured" under the workflow of the item and then you have to terminate the workflow by clicking on the "Terminate this workflow now" link.


I just need to do this function ("Terminating the workflow") in the code in my Catch block where i handle the exception of the workflow activity.


could some one please tell me how to do this? or even point me in the right direction?


i've so far tried varity of:





ActivityBind activityBind = new

SharePoint 2010 Long Starting if start workflow programatically


In SharePoint 2010, I'm starting workflow #2 programatically from my workflow #1. See code below:

					SPList currentList = web.Lists[new Guid(ListId)];
					SPListItem currentListItem = currentList.GetItemById(ListItem);

					//resolve any lookup parameters
					string workflowId = base.ProcessStringField(WorkflowIdentifier);

					//find workflow association by name
					SPWorkflowAssociation workflowAssoc = currentList.WorkflowAssociations.GetAssociationByName(workflowId, Thread.CurrentThread.CurrentCulture);

					if (workflowAssoc != null)
						//start the workflow
						SPWorkflow workflow = site.WorkflowManager.StartWorkflow(currentListItem, workflowAssoc, workflowAssoc.AssociationData, SPWorkflowRunOptions.Synchronous);

And workflow #2  will hang with Starting status (1-10 minutes), Then the workflow #2 status would be modified  to Completed.

I couldn't find how to start the workflow # 2 immediately and complete immediately without several minutes delay

require guideline for 'Role-based authentication/authorization'



In my asp.net website in VS-2005 with SQL-Server 2005 as db, I need to implement role-based Authentication/Authorization.

I am familiar to the practises used in role-based authentication..as I have previously worked on projects that used this method. However, my project lead used to design the database. Now I have an existing website where authentication has been set to anonymous by setting 'allow users="?"' in the authentication tags in web.config.

If I use the createUserWizard control and use the Membership.creatUser(.....) method in code behind will the asp.net security tables, like users, roles, userinrole etc get created on its own? Can anyone please give the proper steps on how to acheive this?

"Save as image" available programatically?

Hi,With the rehosted designer it is possible to right click in the design area and choose to save the workflow as an image. This is cool functionality and was wondering if it was possible to call this programatically? This would then allow me to show an image of what the workflow looks like without having to load up the full designer.Does anyone know if this is possible or how it can be done.ThanksMatt

Change Default Column Value programatically

On a Document Library Settings Page, there is a new setting in SP2010: "Change Default Column Value". Changing the default value of the Field is different from this value. Does anyone know what this value is and where to set it programatically? Also, what libraries is this setting available on? This code updates the field's default value but not the property mentioned above: SPField field = list.Fields["Column"]; field.DefaultValue = "DefaultValue"; field.Update(); Thanks!

Questions about setting dropdownlist selection programatically

I don't understand some things about setting the current selection of dropdownlists from code. I have a dropdown list of people's names where the Value is a Person_ID.  This gets loaded from SQL, and I added an Item which is "Please select..." to the top of the list and gave it a value of 0.  AppendDataBoundItems is true.   If I want to select an item from code can I use dropdownlist.SelectedValue=8 (for example)? Do I also have to set the SelectedItem.Text or does tha above do that for me? Can I instead set the SelectedIndex to some number if I happen to know it?  Will that set the SelectedValue and SelecteItem for me? If I want to set the list back so that nothing is selected (and Please select... shows) should I set SelectedIndex=0?  Is that the same as setting SelectedValue=0 in this case (since "Please select" has a value of 0)? I guess I'm confused on which of these 3 properties I should be using, to select an item (or deselect all items) in the list, using code. Thanks.

Get content of programatically created control before postback

Hi.I have quite a problem here, and hope you can help :)I´ll try to describe the problem in steps, as this might be the easiest to understand:1. Page_Load is called when the page is requested, and calls a BuildTable() method2. The BuildTable method creates a table which contains several textboxes3. the user types some text in these textboxes4. The userthen  changes an item in a Dropdownlist on the page which is intended to change some other content on the page5. Page_Load is called, and afterwards the DropDownListBookingType_SelectedIndexChanged(object sender,EventArgs e) method are called, and the content is changed6. The text the user typed in the programmatically created textbox controls are lost!Now how do I remain this text information? If just the SelectedIndex_changed method was called first, I could save it in session.. But as far as I can tell, all data on the page are discarded when you create a partial postback :(What to do?Thanks alot for your time!

Using ONLY User Certificates for SharePoint 2010 Authentication/Authorization

  Hello, I am relatively new to SharePoint, and was wondering how I can accomplish using only user certificates to authenticate (and eventually authorize) access to the SharePoint 2010 Server (not just IIS). My Environment currently looks like this:  - SharePoint is SSL-enabled - User Browser Certificates (generated using OpenSSL) successfully authenticate to the IIS Server - SharePoint uses Basic Authentication (user/password based on AD credentials) I need to: - Authenticate the user to SharePoint using the User Certificate from my browser (in other words, no password authentication to access the SharePoint website, but use the certificate that was used by iis to be able to log into SharePoint) I am assuming I must use some sort of claims-based authentication.  Ideally, I would like to use ONLY the certification itself as a source of Authorized Repository for authentication. However, I am also open to having the user certificate be linked to Active Directory users as well.  I have done some research on this but am still lost as to how to approach this problem. Is there anyone that has done this or can assist me in getting this to work? Any help would be greatly appreciated. Thanks!  

How to Programatically SetCredentials for Secure Store Service Application in Sharepoint 2010 using

I have to setup Credentials for Secure Store Service application programatically. To get Stored Credentials I have following code and its working fine. using (SPSite site = new SPSite("http://vtlssp2010Dev")) //using (SPSite site = new SPSite("http://" + System.Environment.MachineName + "/sites/Site_Name"))d { Console.WriteLine(site.RootWeb.CurrentUser.Name); SPServiceContext context = SPServiceContext.GetContext(site); prov.Context = context; try { SecureStoreCredentialCollection cc = prov.GetCredentials(appID); foreach (SecureStoreCredential c in cc) { IntPtr ptr = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(c.Credential); string sDecrypString = System.Runtime.InteropServices.Marshal.PtrToStringUni(ptr); Console.WriteLine(sDecrypString); } } catch (Exception ex) { Console.WriteLine("Unable to get credentials for application " + appID); Console.WriteLine(ex.Message); } Console.ReadLine(); } } All I want is to programmatically do set credentials like explained in this example on msdn. http://msdn.microsoft.com/en-us/library/ff798456.aspx Please help. Shamshad Ali  
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