Retrieve data from AD from within a custom sharepoint 2010 webpart

Hi,
I have a requirement to retrieve user data from AD and display from within a custom built webpart.
I am using the PrincipalContext class etc to get the info from AD, i have sucesfully done this in a console program without having to specifiy a username/password.
In the webpart i have successfully retrieved the data by hard coding my domain username/password.
Any ideas what i could do to get the webpart to retrieve information from AD without having to specify username/password?
thanks cjm

Hi C.J, 
I wrote an example of this using credentials stored in the Secure Store in the TechNet Wiki. The article is here: http://social.technet.microsoft.com/wiki/contents/articles/20110.sharepoint-retrieving-credentials-from-the-secure-store-application-using-c.aspx
There's an example in the above article about building a webpart that connects to AD using the credentials.
Regards, Matthew
MCPD | MCITP
My Blog
View
Matthew Yarlett's profile
See my webpart on the TechNet Gallery that allows administrative users to upload, crop and format user profile photos. Check it out here:
Upload and Crop User Profile Photos

Similar Messages

  • Retrieve date/time (timestamp) from MaxDB?

    Hi,
    how to retrieve date and time from MaxDB?

    Hello,
    please try
    select now(), date(now()), time(now()) from dual
    Regards Thomas

  • How to make users to select the date from calendar control my making the date field read only in date time control in external list in sharepoint 2010

    How to make users to select the date from calendar control only, by my making the date text field read only (don't want to let users type the date) in date time control in external list in sharepoint 2010. I am looking for a solution which can
    be done through sharepoint desginer / out of the box.
    thanks.

    Congratulate you got the solution by yourself. I am new to a
    WinForms calendar component, I feel so helpless on many problems even I'd read many tutorials. This question on the
    calendar date selection did me a great favor. Cheers.

  • Retriever data table MARA from R/3 to APO

    Hi,
    I want retriever data from the table MARA in R/3 to APO. I am using the function module 'RFC_READ_TABLE' but the SY-SUBRC not equal to zero and the error is "table_not_available".
    This function work with others tables.(i.e MARC).
    Why the function not work with the table MARA?
    Thanks.

    Hi Nandha,
    I don´t understand your reply. Can you expalin again,please?
    Which is the structure name MARA in APO?
    Thanks.

  • Custom SharePoint 2010 designer page throws "The data source control failed to execute the insert command" exception while adding the new item after the August 13, 2013 CU has installed

    We have the SharePoint Server 2010 with SP1 environment on which the custom SP2010 designer pages were working as expected before the
    August 13, 2013 CU has installed. But, getting the below exception while trying to add the new item after the CU has installed.
    Error while executing web part: System.NullReferenceException: Object reference not set to an instance of an object.     at Microsoft.SharePoint.WebControls.SPDataSourceView.ExecuteInsert(IDictionary values)     at
    System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) 3b64c3a0-48f3-4d4a-af54-d0a2fc4553cc
    06/19/2014 16:49:37.65  w3wp.exe (0x1240)                        0x1300 SharePoint Foundation        
     Runtime                        tkau Unexpected Microsoft.SharePoint.WebPartPages.DataFormWebPartException: The data source control
    failed to execute the insert command. 3b64c3a0-48f3-4d4a-af54-d0a2fc4553cc    at Microsoft.SharePoint.WebPartPages.DataFormWebPart.InsertCallback(Int32 affectedRecords, Exception ex)     at System.Web.UI.DataSourceView.Insert(IDictionary
    values, DataSourceViewOperationCallback callback)     at Microsoft.SharePoint.WebPartPages.DataFormWebPart.FlatCommit()     at Microsoft.SharePoint.WebPartPages.DataFormWebPart.HandleOnSave(Object sender, EventArgs e)    
    at Microsoft.SharePoint.WebPartPages.DataFormWebPart.RaisePostBackEvent(String eventArgument)     at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)     at System.Web.UI.Page.ProcessRequestMain(Boolean
    inclu... 3b64c3a0-48f3-4d4a-af54-d0a2fc4553cc
    06/19/2014 16:49:37.65* w3wp.exe (0x1240)                        0x1300 SharePoint Foundation        
     Runtime                        tkau Unexpected ...deStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 3b64c3a0-48f3-4d4a-af54-d0a2fc4553cc
    I have tried changing the "DataSourceMode" as below, now the insert command is working, but update command is not working.
    <SharePoint:SPDataSource runat="server" DataSourceMode="ListItem" />
    Also, the lookup dropdown fields are displaying the value as "<a href="Daughterhttp://cpsp10/sites/Employees/_layouts/listform.aspx?PageType=4&ListId={8F62F444-FB6A-4F03-9522-C4696B45DCD1}&ID=10&RootFolder=*">Daughter</a>"
    instead of only "Daughter".
    Please provide the solution to get rid of this issue.
    Thanks
    Ramasubbu

    Try below:
    http://social.technet.microsoft.com/Forums/en-US/ae910269-3a0c-4506-844b-e8bc89d95b71/data-source-control-failed-to-execute-the-insert-command
    http://blog.jussipalo.com/2012/01/sharepoint-2010-data-source-control.html
    While there can be many causes for this generic error message, in my case the first parameter or ddwrt:DataBind function inside the SharePoint:FormFields element was
    'i' and I was working with an Edit Form. Changing it to
    'u' as it was with every other FormField fixed the issue.
    <SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="Edit" FieldName="Esittaja" __designer:bind="{ddwrt:DataBind('u',concat('ff1',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Esittaja')}"
    />
    Explanation:
    DataBind operation type parameters (the first parameter) are listed below:
    'i' stands for INSERT,
    'u' stands for UPDATE,
    'd' stands for DELETE.
    http://webcache.googleusercontent.com/search?q=cache:d9HHY4I7omgJ:thearkfloats.blogspot.com/2014/03/sharepoint-2010-data-source-control.html+&cd=4&hl=en&ct=clnk&gl=in
    If this helped you resolve your issue, please mark it Answered

  • Move workflow status column from one library to another in Sharepoint 2010

    Good morning,
     I have two libraries in the same site, LibraryA and LibraryB.
     On LibraryA, users upload documents upon which they start a collect signatures workflow. The view on LibraryA contains a column with the signatures workflow name showing status: ‘Compete’, ‘In progress’.
     Now on LibraryA I have created a workflow to move any document one month after creation to LibraryB (using retention schedule) irrespective of signature workflow status.
     Now what I would like is to have the signature workflow status shown in LibraryB as well. From what I understand you can add the workflow status column only on the library with which the workflow is associated. I also tried, on LibraryB, to create a new
    column which Lookups in {Signature Approval History – Outcome} but this did not do the trick either.
     Any workarounds?
     Many Thanks

    Hi,
    According to your description, my understanding is that you want to move the workflow status column to another library in SharePoint 2010.
    I recommend to use another column to get the value of the workflow status column and then move this column to another library.
    We can use workflow to update the column with the value of workflow status column.
    However, the workflow status column stores the value with numbers which represent different status, so we need to update the column with corresponding status based on the numbers in the workflow.
    http://chanakyajayabalan.wordpress.com/2010/03/08/sharepoint-workflow-status-codes/
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Created By and Created Date fields not showing up on Custom List form webpart

    Hi,
    I have added Custom Listform WebPart on "DispForm.aspx" of custom list. I need to display, out of box fields "Author" [Created By] and "Created" [Creation Date] on this custom list form webpart, I have added them on the webpart, following is the code behind of aspx page:
    <td width ="400px" valign= "top" class="ms-formbody">
    <xsl: value-of select = "@Author" disable-output-escaping = "yes"/>
    </td>
    However these fields are not showing/populating data on the form ?? Any inputs ???
    Regards

    Hi,
    I think that when you insert a custom list form web part you select “Item” content type, so custom list form is designed to display only the fields that are appropriate for that content type “Item”, but the item content type doesn’t contain the created and created by column, when you add the two columns, it will not find the field value. By default, the two columns will display at the foot of the list form using SharePoint:CreatedModifiedInfo.
    Hope it can help you.
    Xue-Mei Chang

  • Can't retrieve approval status in Globally Reusable Workflow (Approval - Sharepoint 2010)

    For day's i am trying to implement the following in one of the standard, out of the box, Globally Reusable Workflow with Sharepoint Designer 2010:
    If Current Item:Approval Status not equals 0:#Approved Start Approval Workflow Task process on Current Item with Parameter:Approvers Else //Nothing
    This is to prevent that a workflow is started if the item is already approved! The strange thing is, a buddy of mine has also Sharepoint 2010 and he can select in the DropDown list -Current Item: -> Approval Status..
    But the only things I can select are the following:
    Content Type
    Created By
    ID
    Modified
    Modified By
    Title
    I don't understand what is going wrong! What am i forgetting to configure or bind or set?

    I have found the solution!
    I have setup an test environment, Sharepoint 2013 on MS Server 2008R2 and installed Sharepoint Designer 2013. When I now edit the default out of the box "Approval - Sharepoint 2010", if you enter the condition "if current item field equals value", you can
    now select "Approval Status"!!
    So this means that it IS available after all! After a lot of trying, searching, this is the solution in a Sharepoint 2010 environment, installed on MS Server 2008R2:
    Edit the (global or copied version if you want) workflow.
    Add the condition "if current item field equals value" as a step.
    Select from the item field: Content Type
    Click on "equals" and change it to "not equals"
    Then click on the condition and enter manually the following: 0;#Approved
    Move the task "Start Approval Workflow Task..." up so it is a part of the condition "If.. "
    Add an Else condition
    Enter here your custom action or log to show the user that the Task is not performed.
    Save the workflow.
    We now have to manually edit the Workflow Rules file.
    In Sharepoint Designer 2010, click at the left side of the ribbon on "All Files".
    If you have created a custom workflow, you can find the "Workflow.xoml.rules" file, in the folder
    Workflows/"Your custom workflow"/"CustomWorkflow.xoml.rules".
    If you are using the global, out of the box Workflow, you can find the .rules file in:
    _catalogs/wfpub/Approval - SharePoint 2010/ReviewApproval_1033.xoml.rules
    Click on the file, then in the next screen click on "Edit file" under Customization. 4.Search for the string "ContentType" 5.When you have found the string, it looks a bit like this:
    ns1:String xmlns:ns1="clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">ContentType ns1:String
    (When you look a few lines below this line, you see your added condition 0;#Approved)!
    6.Replace the string ContentType with: _ModerationStatus 7.Save the file! 8.Open in the current directory the "Workflow.xoml" file (this is the workflow itself) 9. Click on the Save button, it will give you a notice:
    A more recent version of _catalogs/wfpub/Approval - SharePoint 2010/ReviewApproval_1033.xoml.rules has been saved to the server by "user" on 1/5/2014 10:50 AM.
    Do you want to replace this with your file?
    Click NO! (Important, otherwise it will replace it with the default rules file, and nothing has changed!)
    Close Sharepoint Designer 2010, reopen SPD2010 and go to the workflow.
    Edit the workflow and you'll see the following now:
    "If Current Item: equals 0;#Approved"
    The field Content Type is now gone! This is correct so don't worry!
    Publish the workflow and you are done!
    Check now on a library that has a link to the edited workflow, when you start a new Workflow on a Approved-Major version of the document, what the outcome is:
    The workflow is discarded because of the condition and nothing happened, so your document stays on the most recent Approved-Major version and is not published back to a previous version number!!
    Conclusion: I think that the Sharepoint 2010 Designer, is missing that specific "Approval Status" field, but with the solution i have just given, you can solve this!
    C# for the win!

  • How to Get current username in custom SharePoint 2010 master page

    Hi,
    How can I get current logged-in username in SharePoint 2010 custom master page?
    Regards,
    Amit

    You can use the SPContext.Web.CurrentUser object to get at the information you're looking for. This can be accessed either via client-side JavaScript or server-side ASP.NET code.
    Getting the logged in user's login and name via JavaScript:
    <script>
    ExecuteOrDelayUntilScriptLoaded(function(){
    var clientContext = SP.ClientContext.get_current();
    var CurrentUser = clientContext.get_web().get_currentUser();
    clientContext.load(CurrentUser);
    clientContext.executeQueryAsync(Function.createDelegate(this,function(){
    // User's Name
    alert(CurrentUser.get_title());
    // User's Login
    alert(CurrentUser.get_loginName());
    }),Function.createDelegate(this,function(sender,args){alert(args.get_message())}));
    },"SP.JS");
    </script>
    And of course, it's even easier via server-side C#:
    <script runat="server">
    String username = SPContext.Current.Web.CurrentUser.Name;
    String userlogin = SPContext.Current.Web.CurrentUser.LoginName;
    </script>
    I hope that helps!

  • SharePoint 2010 webpart from word or pwr point. How to import or copy into SP 2010 (colored tile boxes with links)

    Dear SharePoint Forum,
    How do I import or create a colored tile screen from material created in Word or Pwr Point. The copy/Cut paste feature does now work..Is this custome HTML or J script or is there a special webpart for this type of SP 2010 work?
    Thanks,
    M. Breton (Misa)

    Dear SharePoint Forum,
    How do I import or create a colored tile screen from material created in Word or Pwr Point. The copy/Cut paste feature does now work..Is this custome HTML or J script or is there a special webpart for this type of SP 2010 work?
    Thanks,
    M. Breton (Misa)

  • Export all the lists/libraries from moss 2007 then import to sharepoint 2010

    Hi All
    I am looking to get a script which export's all the list/libraries in moss2007 then import into sharepoint 2010.  Please help me out.
    I have qus here, it will take care about the user security ?
    Thanks  in advance.
    Subhash

    Inderjeet, just a quick pointer about this utility.  The guy behind it is a UK based MVP, who's mentioned in the tool description that it's not an upgrade tool.  I just think that should be kept in mind before offering it as a solution.
    Subhash, if you've not got a lot of content to move and don't mind installing a third party tool,  Metalogix Content Matrix Express edition would work perfectly for this need.  It's also free.
    http://www.metalogix.com/Resources/Promotions/Content-Matrix/Content-Matrix-Migration-Express-Download.aspx
    Steven Andrews
    SharePoint Business Analyst: LiveNation Entertainment
    Blog: baron72.wordpress.com
    Twitter: Follow @backpackerd00d
    My Wiki Articles:
    CodePlex Corner Series
    Please remember to mark your question as "answered" if this solves (or helps) your problem.

  • Information query SQL in list custom SharePoint 2010

    Hello Guys,
    Need some help with a custom list on a project site. 
    Prepared the following code:
    SELECT 
    Webs.Title,
    Lists.tp_Title,
    Webs.TimeCreated,
    nvarchar3,
    nvarchar4,
    nvarchar5,
    nvarchar6,
    nvarchar7,
    nvarchar8,
    ntext1,
    ntext2,
    nvarchar9,
    nvarchar10
    FROM Webs 
    INNER JOIN Sites ON Webs.SiteId = Sites.Id 
    INNER JOIN UserData ON Sites.Id = UserData.tp_SiteId 
    INNER JOIN Lists ON UserData.tp_ListId = Lists.tp_ID
    WHERE Lists.tp_Title = 'ListName' AND
    Webs.Title = 'ProjectName' 
    ORDER BY Webs.Title
    In database SharePoint_Content.
    The code works fine, but it brings me all the information I need. 
    But do not bring me what options were marked in the list by the user. 
    The question is: Is there any field that I can pull only the options that have been marked? 
    Thanks for your help.
    Obrigado por contactar o fórum Microsoft Technet!

    Can you describe as to what you are trying to achieve? Writing T-SQL queries and fetch data from SharePoint databases is not supported.
    This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

  • Issue with Copy of events from Outlook Calendar to SharePoint 2010 calendar(mapped in outlook)

    There is a issue while copying events in Outlook mapped SharePoint 2010 Calendar.
    This issue only seems to happen when user copies an event from his Outlook calendar to the SharePoint 2010 calendar. 
    He is able to create a new event in the SharePoint calendar from Outlook. 
    He tried below steps, but still no success
    1.
    Open your Outlook calendar.
    2. Open the event you want to copy.
    3. From the File menu, select Info.
    4. Click the Move to Folder button.
    5. In the Copy Items To dialog box, scroll down to the SharePoint Lists item and select the SharePoint calendar to which you want to copy the event.
    6. Click the OK button.
    7. Click the Yes button when prompted to continue. 
    Please let me know if there is any possible solution for it.

    Hi,
    I have done a test as your steps. I am able to copy an event from my Outlook calendar to the SharePoint 2010 calendar.
    1. I suggest you test in another compute, perhaps your Outlook results to that issue.
    2. Please create a new site collection, then test again, compare the result.
    3. Maybe it will take some time before the copied event displays in the SharePoint 2010 calendar. So, wait a minute, compare the result. 
    Best Regards,
    Wendy Li
    TechNet Community Support

  • Date picker is not working in IE9 for sharepoint 2010 appliation pages

    Hi,
    Date picker not working  in IE9 for sharepoint 2010 appliation pages. We have enabled custom master page.
    Thanks in advance.
    Shameej

    Hi,
    For this issue, you can add the following line of code into the pickerdialog.master which lays in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS
    <meta http-equiv=”x-ua-compatible” content=”IE=8”>
    Or we can use the JavaScript code provided in this blog which would also do the trick:
    http://williamwmy.wordpress.com/2013/06/03/problem-with-sharepoint-peoplepicker/
    A thread with the same issue for your reference:
    http://sharepoint.stackexchange.com/questions/27251/hotfix-for-problem-with-sharepoint-peopleeditor-in-ie-9
    Best regards
    Patrick Liang
    TechNet Community Support

  • Custom SharePoint Connector with FAST: Language Detection

    Hello. I've got a custom SharePoint 2010 Connector working with FAST.
    Almost works fine, but there is a little problem: FAST doesn't want to detect language.
    And when I set any language in Advanced Search I've got empty results, because property DetectedLanguage is empty.
    So, I've tried to set default fallback language (as it shows in
    http://support.microsoft.com/kb/2711004)
    But it doesn't help.
    p.s. In SharePoint 2013 it works.

    Hi Mikhail,
    According to your description, my understanding is that set default fallback language does not work in your SharePoint 2010.
    For your issue, you need to install the April 2012 Cumulative Update for FAST Search for SharePoint 2010 which allows you to define a fallback language and character set when automatic detection of the language and encoding fails.
    URL for April CU 2012 http://support.microsoft.com/kb/2598329
    For more information, you can refer to the blog:
    http://blogs.msdn.com/b/ravipriya_de_alwis/archive/2013/03/28/language-detection-and-fallback-language-for-fast-search-for-sharepoint-2010.aspx
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

Maybe you are looking for

  • I've tried everything to get my phone out of recovery mode but nothing is working.

    Hi, I recently started updating my phone to I.O.S 8.1.3, and it was downloading and updating fine, then it said it had an error updating. I turned it off and on again to see if that would work, and when I clicked install it showed up as if it was tur

  • Date vs. Day of the week

    Maybe I am dense, but I can't figure out a way to set my calendar for a meeting the first MONDAY of each month without doing it manually 12 times. Suggestions? Thanks!

  • PO, PR creation authorisation restriction based on Internal Order

    Dear Forum We have created a new Interla order type and want that only selective users can make a PO or PR in the Internal orders of that Intenal order type. Is there any way by which we can restrict creation of a PO or PR against an Internal Order,

  • Polling from the database view in BPEL 11g

    Hi, We do have a requirement of polling from the database view in BPEL 11g. I am exploring the following polling strategies in our case: - Delete - Logical Delete In case of Delete polling strategy, can we delete the record as the view does not allow

  • URL Authentification every time in the session

    Hi, I have protected an URL with AD authentification. So, I've created an "Authentification Provider " and I put in web.xml the name of the url.It works fine but I would like the application to ask for authentification every time we go to this URL in