visual studio 2010 - How to get user Names of domain in Sharepoint web part? -
I want to get user names in Active Directory using SharePoint WebPart. Either way I can get the user name using ASP Net but I can convert that part to SharePoint Web Part ....
Here is the code .........
System use; Using System.Collections.Generic; Using System.Linq; Using System.Web; Using System.Web.UI; Using System.Web.UI.WebControls; Using System.DirectoryServices; Using System.Data; String domain = "LDAP: // servername"; DirectoryEntry entry = new directoryInterity (domain); Directory Finder Explorers = New Directory Finder (Entry); Finder.filtor = "(and (object class = user))"; Search ResultCollection resultCol = searcher.FindAll (); // Link List for List of Store User Name & lt; String & gt; User_Names = New list & lt; String & gt; (); Int count = 0; Foreach (Results in search results result results) {User_Names.Add (Results Properties ["CN"] [0] .Ostring ()); Calculation = count + 1; } // All user names can be printed for use by loop or while Loop Label2.Text = RadioButtonList1.SelectedItem.Text;
There is a little bit you need to get started. This is a skeleton for a .NET Web Part class that includes data-bound radio button list
to be employed on SharePoint, you must roll out a proper .webpart manifest together. There are many examples of these on the web, and Visual Studio 2010 Projects for SharePoint 2010 have made it super easy with the Visual Web Part template. (Note that if you are using Visual Web Part template, you can write a Web Part with a .ascx file like any other user control instead of using CreateChildControls ()
Below.)
Good luck!
System Using Web.UI.WebControls; Using System.Web.UI.WebControls.WebParts; /// & lt; Summary & gt; /// This web part provides redirection logic on one page. /// & lt; / Summary & gt; Public Class Redirect Web Page: Systems Web. UI. WebControl Wiibert WebPart {/// & lt; Summary & gt; /// makes child control /// & lt; / Summary & gt; Protected Override Zero CreateChildControls () {base.CreateChildControls (); Radio button list = new radio button list (); Controls.Add (list); List.AutoPostBack = True; List Selected indices + new event handler (this .one-named name changed); // Next Line, Aditytie GetActiveDirectoryNames () is a dummy / class and method that you should change with your ady query logic. // It just needs to return a huge collection of strings. List.DataSource = ADUtility.GetActiveDirectoryNames (); List.DataBind (); } Secure zero-on-name renaming (object sender, eventAggas E) {// Your Event Handling Logic }}
Comments
Post a Comment