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

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Getting right data from ActiveDirectory for single sign-on

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :Windows Application


I need to list all the groups and users in the current Active Directory and this is done by the following code :

public static List<ActiveDirectoryTreeNode> GetGroups()
      DirectoryEntry objADAM = default(DirectoryEntry);
      // Binding object. 
      DirectoryEntry objGroupEntry = default(DirectoryEntry);
      // Group Results. 
      DirectorySearcher objSearchADAM = default(DirectorySearcher);
      // Search object. 
      SearchResultCollection objSearchResults = default(SearchResultCollection);
      // Results collection. 
      string strPath = null;
      // Binding path. 
      List<ActiveDirectoryTreeNode> result = new List<ActiveDirectoryTreeNode>();

      // Construct the binding string. 
      strPath = "LDAP://stefanserver.stefannet.local";
      //Change to your ADserver 

      // Get the AD LDS object. 
        objADAM = new DirectoryEntry();//strPath);
      catch (Exception e)
        throw e;

      // Get search object, specify filter and scope, 
      // perform search. 
        objSearchADAM = new DirectorySearcher(objADAM);
        objSearchADAM.Filter = "(&(objectClass=group))";
        objSearchADAM.SearchScope = SearchScope.Subtree;
        objSearchResults = obj

View Complete Post

More Related Resource Links

Single Sign-On: A Developer's Introduction To Active Directory Federation Services


Use Active Directory Federation Services to allow other organizations to use your Web applications without the need for you to grant access explicitly.

Keith Brown

MSDN Magazine November 2006

Using the single *.rpt file with multiple data sources


I've created a set of CrystalReports (*.rpt files) for an ASP.NET web app on a development server. I call each report using the following code:

protected void BTN_RunReport_Click(object sender, ImageClickEventArgs e)
CrystalReportViewer_ClientLetter.Visible = true;

ConnectionInfo con = new ConnectionInfo();
con.ServerName = Constants.ServerIP;
con.DatabaseName = Constants.DatabaseName;
con.UserID = Constants.UserID;
con.Password = Constants.Password;

CrystalReportViewer_ClientLetter.ReportSource = Server.MapPath(Constants.ClientLetters);
ParameterFields parameter = CrystalReportViewer_ClientLetter.ParameterFieldInfo;
ParameterField batchdate = new ParameterField();
batchdate.Name = "@BatchDate";
ParameterDiscreteValue batchdate_value = new ParameterDiscreteValue();
batchdate_value.Value = Convert.ToDateTime(txtBatchDate.Text);

foreach (TableLogOnInfo tlf in CrystalReportViewer_ClientLetter.LogOnInfo)
tlf.ConnectionInfo = con;

MVC, Single-Sign-On and Roles

I have basic Single Sign-On working across 2 MVC sites (call them SiteA and SiteB) using something along the lines of the following method:http://forums.asp.net/p/1023838/2614630.aspxThey are on sub-domains of the same domain and share hash\encryption keys etc in web.config. I've modified the cookie so it is accessible to all Sites on the same domain. All of this seems to be working ok.The sites are on seperate servers without access to the same SQL database, so only SiteA actually holds the user login details. SiteB has a membership database, but with empty users.This works fine for my required scenario which is:1) User logs into SiteA2) The application loads data from SiteA (by AJAX) and SiteB (by AJAX using JSONP)I have the following LogOn Action on my AccountController for SiteA, which is where the "magic" happens: [HttpPost] public ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { if (MembershipService.ValidateUser(model.UserName, model.Password)) { FormsService.SignIn(model.UserName, model.RememberMe); //modify the Domain attribute of the cookie to the second level of domain // Add roles string[] roles = Roles.GetRolesForUser(model.UserName); Http

Can i use Single Sign on Sharepoint 2010?

Can i use Single Sign on Sharepoint 2010?

Best way to display data of a single column from a Sharepoint Custom List

I'm trying to create pages that will automatically populate with data pulled from a sharepoint list (like title, department, contact info, etc.).   I'm using publishing pages. What would be the easiest way to do this, and how would I specify which data to pull from the list? For example, the page would be set up like this: [Title:biology] [Department:biology] [Contact Info:biology]   and when the page loads, it would look like this: Biology Lab Biology Department 123-456-7890   I want it to just pull the data -- I don't want a list view or anything like that.  I need this page to look pretty, and I need the each column's data to show up in a very specific place. How could I make pages that would do that?

Single Sign On to external system via iView?

I have Page iView in the SharePoint 2010. I have another non MS based external system where I should make integration. iView is great, but I need authentication as well. What is needed to create SSO to authenticate to the external system and display view to the external system via iView? Is it mandatory to external system to support SSO? Both SharePoint and external system have SSO account mapping?Kenny_I

Implementing Single Sign-On using SAML 1.1, x.509, LDAP in C#.net

Hi, I got a requirement from the client i.e implementing single sing on using SAML 1.1( LDAP & X.509)in .net. I searched almost entire internet but no use. I have perfect knowledge regarding SAML but i dont know how to implement it in C#.net. Where do i get any papers or document that tells how to implement SSO using SAML in .net . What are the key steps involved in implementing it? What are the topics i need to cover to complete this task. I am literally struck at this point, any help would be apprciated. Thanks in advance sam

Single Sign On for Sharepoint and external applications

We would like to set up our Sharepoint 2010 Server to allow for single sign on. Right now when a user accesses the site, they are prompted for their username and password, whenever they open a file from a document library they have to put in their username and password. I am sure there is a way that we can set up Sharepoint to not require this every time they access the site and/or documents, by using their windows login like Dynamics CRM does.   Can anyone assist us in getting this set up properly? Thanks in advance!


the database result is as follows DATE     code   class1 class2  class3 1/8/10     M1     10       20     30     3/8/10     V2      20       30     10      1/8/10      H1      1           2      3         7/8/10     ! ! 8/8/10     !M2    5      5      5       3/8/10     B2      4      4     4       1/8/10     V1      3      7     3       THE OUTPUT SHOULD BE AS FOLLOWS:- DATE           M1                          M2           

How Configure Sharepoint Single Sign-On for External Domain User?

Hi, Good Day All, How to configure MOSS 2007 single sign-on For External Domain User, these external domain users are in the members of internal domain but when they access portal out side the domain then portal ask his credential. Is there any way to provide/Configure Sign Sign-On facility for External Users. Thanks, Iftikhar Hashmi

Problems with single quote character when attempting to export data from SQL Server

Hi, I am attempting to use the following query, which works fine when run in sql server management studio, to export data: SELECT             '1',             isnull(left(DISTRICT,1),' '),             isnull(left(CTV,2),'  '),             isnull(left(CTV2,5),'     ')           FROM [CensusData].[dbo].[MainQuestionnaire$] The export command follows: EXEC xp_cmdshell 'bcp "SELECT             '1',             isnull(left(DISTRICT,1),' '),             isnull(left(CTV,2),'  '),             isnull(left(CTV2,5),'     ')             FROM [CensusData].[dbo].[MainQuestionnaire$]" queryout "C:\bcptest.txt" -T -c -t -S "MYSERVER"' The error is: Incorrect syntax near '1'. I believe that the problem is with the single quote characters but don't know how to fix it. I am using SQL Server 2005 Express edition. Please help.

how to display multiple calendar list data in single calendar view

Hi, Normally, we can used to extend the ListViewWebPart's ViewType property to display a particular calendar list items in Calendar View in our custom webpart. Is it any way to display multiple calendar list data in a single calendar view ?? or please provide some pointers related to this issue. Any help is much appreciated.    

Single Sign On Web and Windows Apps

Hello, We, at our company, are developing a file sharing application which will allow users to upload/download files. This application will be part of the suite of other applications. We will be adding a desktop client (windows app) which is an upload/download manager which will assist users to queue in multiple large files for upload/download.  There are a couple of questions related to design for these applications: 1. We would like to implement Single Sign-On for all these applications (including desktop client). We would like users to login to web and once they do that, they can browse through applications without logging in again. We will be implementing a authetication service using WCF. The requirement is that we do not want to add authentication functionality to desktop client. So users will need to login to our web application.  We can write cookie to user's machines and will work for web applications. Can the desktop client use the same cookie to autheticate itself? Or there are other ways we can achieve it? 2. We also do not want that when desktop client is uploading/downloading multiple files that its session is expired and the user need to re-authenticate through web. How can we achieve it? How does other Upload/Download Managers (like MS File Trasnfer Manager) work? Any help in this regard is appreciated.

LIKE Condition - Single Percentage Sign Matching?


What is the expected behavior when a LIKE condition specifies a single percentage sign? For example, if I have a Customer table with a CustomerName field and I write the following SQL Query:

SELECT * FROM Customer WHERE CustomerName LIKE '%'

  1. Does the single percentage sign negate the LIKE condition?
  2. Would this specific statement be equal to just SELECT * FROM Customer?
  3. Finally, does this work with all data types, or just char/nchar/varchar/nvarchar?

Expose data contract used in two services as a single type on client side?


I have a .dll that contains my data contracts and I reference this dll in two different services.

Now, on the client side I don't want to add this dll because I need both WPF-clients and Silverlight clients. So, what I want is to be able to use a single data contract on the client side and not with different namespaces for the different services. As I understand this should be possible but I don't know how.

Can someone explain how I can generate a single data contract on client side that can be used for calls to both services?

Thanks for help!

Insert/Update data to multiple tables on a single button click


Hi experts,

I need to insert/update data to 3 or more tables on a single button click.What is best method for achieving this?I am using mysql as my DB.

Thanks for your valuable reply in advance.

need help about Single Sign On in asp.net


Hello friends 

I am trying to use the concept of Single Sign On (SSO) in my asp.net application. 

for the purpose i have created a main domain say mydomain.com

now i have 2 subdomains sub1.mydomain.com & sub2.mydomain.com. 

I am running these very fine. But now I want to have a SSO for my domains. For the same have 

googled lot and found some stuff such as adding machine key to web.config and specifying domain names in cookies. 

But it is not at all working for me. when I specify the domain name for cookies i am unable to sign out. 

I am using FormsAuthentication in asp.net. 

Following is the code I have in my web.config.

<authentication mode="Forms">
	<forms name=".ASPXFORMSAUTH" path="/" loginUrl="myHome.aspx" protection="All" timeout="1339" domain="mydomain.com">
<machineKey validationKey="21F090935F6E49C2C797F69BBAAD8402ABD2EE0B667A8B44EA7DD4374267A75D"
				decryptionKey="ABAA84D7EC4BB56D75D217CECFFB9628809BDB8BF91CFCD64568A145BE59719F" validation=&quo
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