.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

Copy and Maintain Active Directory User details into mysql table using C#

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

For a given Domain name how can I retrieve the AD User details including a Unique identifier so that any changes to the user details including the username can be updated using the unique Identifier.

I can use System.DirectoryServices.DirectoryEntry to get the user details but not able to figure out how to work with the Unique Identifier to maintain the user details consistently.

Please provide me with some sample.

Thank you

View Complete Post

More Related Resource Links

Error on Display user's fullname using Active Directory in asp.net using vb.net



wi As System.Security.Principal.WindowsIdentity =  _System.Security.Principal.WindowsIdentity.GetCurrent()



Dim a As String() = HttpContext.Current.User.

Active Directory user impersonation with forms authentication

I've written a small ASP.NET 3.5 application to allow users to update selected account attributes on their own. Everything works fine when I use Basic Authentication, but because the dialog that is presented is less than ideal, I'd like to use forms authentication to give the users more instruction on how to log in. My problem is that in order for the user to update their account information, I have to have the application impersonate them for the update actions. I've scoured the internet trying to find a solution to my issue, but nothing fits or works. I have tried setting the web.config:<identity impersonate="true" /> but that doesn't seem to work. I also have the C# code using the WindowsImpersonationContext class, but still no luck. protected void titleTextBox_TextChanged(object sender, EventArgs e) { TextBox tb = (TextBox)sender; string fieldTitle = "job title"; string fieldName = "title"; if (userDirectoryEntry == null) CaptureUserIdentity(); try { WindowsImpersonationContext impersonationContext = userWindowsIdentity.Impersonate(); if (String.IsNullOrEmpty(tb.Text)) userDirectoryEntry.Properties[fieldName].Clear();

Import user profile from another domain active directory

Hi, I have SharePoint 2010 running on DomainB andwe have corporate users on DomainA. i need to import users from both domainA and DomainB. I am able to import users from domainB and not able to import users from DomainA. I made a successful connection to both Domain A Ad and DomainB AD in SharePoint 2010 user profile synchronize connections. I am able to sync users only from DomainB (SharePoint 2010 running on domainB) and not able to synchronize profiles from DomainA (outside domain). Is there any additional configuration I need to do. Please help me on this issue. Thanks, Ratna

Maintain users and groups list of Active Directory for an asp.net web application only

Hi, I have configured active directory in my server 2008. We have a web project using asp.net mvc named Audit planning and Execution Software(Apex2).What we want to do is to authenticate Active directory users for this project.I can get all active directory users, groups, users of a group etc.I want to add users in active directory for the Apex2 project only using asp.net.I also want to display only the users and groups of Active Directory registered with the Apex2 project only. And I also want to add active directory users from whole AD list to our project's AD list. Can you please tell me, how will I do this. Shall I create an Organizational Unit and maintain all users and groups there for our project? Or, is there any other way to do this?  please help me.Thank You

Unable to see Active Directory Groups in the User Profile Database after Profile Import

SharePoint Server 2010 Enterprise RTM. W2K8R2 w/multi-server setup: AD/DNS SQL 2008 WFE APP Claims Mode Web App only using Windows Integrated Auth So, this was never a problem in 2007, and I didn't even realize it was a problem in 2010 until I started to build a solution that utilized my blog article: InfoPath - User Roles in Browser-Enabled Forms Using AD Groups.  I went to utilize the same web method of the same web service, but I noticed that no data was showing up at all.  Typically, the GetUserMembership/GetCommonMembership methods return the specified user's memberships: AD Security Groups, AD Distribution Lists, and SharePoint Sites (not SharePoint Groups, though). My user profile sync is working.  All AD users are pulled in with the proper profile data. "Users and Groups" is selected in the Synchronization Entities section of my Sync Settings. Security groups are working for permissions and audience targeting.  Confirmed my users are affected properly by the use of Security Groups. My query to the GetUserMemberships web method (and GetCommonMemberships) is running (not failing), but it's not returning anything even though my user is in some Security Groups and has explicit membership to multiple sites. The GetUserProfileByName method of the same UserProfileService.asmx web service returns all the regular profile data

Is there a way to undo/remove/delete an active directory user profile syncronization? [SP 2010]


I successfully managed to synchronize the active directory with Sharepoint 2010.  Unfortunately, the farm I was on has different FQDN /Netbios domain names.  So all ~1000 user profiles are now imported with the wrong domain, and the subsequent errors one would expect.


Is there a way to get back to a blank slate?  technet has an article on "resetting" profile synchronization (http://technet.microsoft.com/en-us/library/ff681014.aspx), but that requires being able to verify the GUID of the user profile synchronization database, which I am also unaware of how to do.


Please help, and thank you in advance.

Active Directory User validation field in ASP.NET


I like to add a field that add active directory user in ASP.NET Web Application .




Thanks in Advance



Active Directory - User Deletion - Sync with MOSS 2007


Greetings -

I need to know if there is a sync tool that can scan all sites in a site directory and remove users that have been deleted or marked inactive within Active Directory?  I work in a company which has freaquent turn over in some positions due to internships and the like and I want to ensure that we have clean site permissions. 

Thank you for any suggested sites or addins. 


Accessing Active Directory's User Profile Information in InfoPath Form



I want the User Profile information in InfoPath Form from active directory and I want complete information of currently logged in user which include:

User Name, First Name, Last Name, Email Address, Designation, Company, Manager Name and everything which is in the profile of user in Active Directory. Please help me in getting this.


M Kamran Rafi

Can I pass a user's active directory group as a parameter to reporting services?


Hi there,

I am wondering if I can pass a user's active directory group as a parameter to reporting services? If so, how can I do that (e.g. where can I get that group from?)?

Is there something as User.UserID for active directory groups?

Many Thanks and best wishes



Moving User In Active Directory - ASP.NET VB



Can anyone help with an error I am recievibg when trying to move a user in Active Directory, The error is -2147016672 - An Operations error occured

    Sub UpdateUser(ByVal vUsername, ByRef vFirst, ByRef vSurname, ByRef vJobTitle, ByRef vDepartment, ByRef vLocation, ByRef vPhone, ByRef vCompanyName, ByRef vDirectorate)

        Dim vCapitaAD As New DirectoryServices.DirectoryEntry("LDAP://Domain.com/DC=Domain,DC=COM", vADUserName, vADPassword, AuthenticationTypes.Secure)
        Dim mySearcher As New DirectorySearcher(vCapitaAD)

        mySearcher = New DirectorySearcher(vCapitaAD)
        mySearcher.SearchScope = SearchScope.Subtree
        mySearcher.Filter = ("(samaccountname=" & vUsername & ")")

        Dim result As DirectoryServices.SearchResult = mySearcher.FindOne
        Dim vUsrObj = result.GetDirectoryEntry

            vUsrObj.InvokeSet("givenname", New Object() {vFirst})
        Catch ex As Exception
        End Try

            vUsrObj.InvokeSet("sn", New Object() {vSurname})
        Catch ex A

Changes in Active Directory not reflected in SharePoint user info



I have a client who uses WSS 3.0 w/ SP1, and does not want to move to MOSS 2007.  The client will be migrating to Exchange 2007 soon, and part of this migration will include populating attributes for the user objects in Active Directory so that the phone numbers, addresses, departments, etc are all stored in AD.  The problem is that the mojority of the user base has already used SharePoint, and when each user first used SharePoint, their info was imported from AD.  Is there a way to force an import so that all the user info in SharePoint will be updated based on what is in Active Directory?  Is it possible to do it in the reverse direction so that users can update their info in SharePoint, and have it write back to their AD user object?


-Derek Brown

Sr System Engineer



automatically determine active directory user name

hey there

my situation is the following:
i need some kind of automatic user authentication for some intranet page of a company.
whenever anybody of the company is surfing on this webpage, i need to determine the active directory user name and the name of the active directory user group that user belongs to.

maybe somebody knows a solution ;)

thanks in advance,

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.

Get User data from Active Directory


I have Custom List which is having IDNo, First Name, Last Name, Email & Office. I want to make it when User enter IDNo, Automatically fill other fields (FirstName, Last Name...etc) from Active Directory). Is that possible to do Using JavaScript?




Active Directory User Shares - Connecting to Share Parent instead of Share


Hi all -

I'm having a bit of an issue. I just started at a job and have a terrible mess to deal with in the wake of my predicessor.

the main problem that i'm looking to fix right now is this:

The staff at my organization have a shared drive that is located at \\fs1\staff$\%username%

Sometimes (maybe 30% of the time) users will log on and they will connect to \\fs1\staff$ and, thus, be able to view everyone's user folders. Now i have restrictions set up so that the users cannot access each others folders, but they can still see them and it is causing a riot amongst the employees.

I would greatly appreciate any insight as to what could be causing this.

I am willing to provide any information that is required (i know i was vague, but I'm not really sure what to include)

thanks all

How to Change password of Active Directory user in ASP.net (c#)



 I have written code in asp.net on button Click


DirectorySearcher mySearcher = new DirectorySearcher(_entry);


SearchResult searchResult = mySearcher.FindOne();


DirectoryEntry objDirectoryEntry = searchResult.GetDirectoryEntry();


if (searchResult != null)



"ChangePassword", new object[] { "OldPassword", "NewPassword1234" });



 I am getting error

Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME)) active Directory

please help me how to resolve this error.



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