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


Top 5 Contributors of the Month
Kaviya Balasubramanian
Sgraph Infotech
Imran Ghani
Post New Web Links

List Users from Active Directory

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net
 

When i try to List the users from Active directory, i get this exception.

Error while processing.System.Runtime.InteropServices.COMException (0x80072020): An operations error occurred at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) at System.DirectoryServices.DirectoryEntry.Bind() at System.DirectoryServices.DirectoryEntry.get_AdsObject() at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne) at System.DirectoryServices.DirectorySearcher.FindAll()

The code i used is :

DirectoryEntry de = new DirectoryEntry(_path);DirectorySearcher deSearch = new DirectorySearcher();

deSearch.SearchRoot =de;

deSearch.Filter = "(&(objectClass=user) (cn=" + UserName +"))";

SearchResultCollection results = deSearch.FindAll();

 But the DirectoyEntry method is getting validated if i use the overloaded method : DirectoryEntry(_path, domainAndUsername, password);

Please advice me.


View Complete Post


More Related Resource Links

Getting list of users reporting from specific Manager from Active Directory

  

Dear All,


I am have requirement like displaying all the user information reporting to specific manager from Active Directory.


Please help me regarding this.


Regards

Prakash


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

Function retrieving users by country against (Active Directory) LDAP

  
Hello I've got such openquery SELECT * FROM Openquery(ADSI, 'SELECT EmployeeID, displayname, mailAddress, country FROM '' LDAP://MY-LDAP-PATH '' WHERE country=''coutry_code' '   ') country_code is 3 letters i think sth in format like USA, FRA etc I will need to retrieve users from up to 3 countries let say and i would like to create from this query above a stored procedure (or better a FUNCTION)  where someone calling a function can specify from which country does he/she wants to terieve users - when none country specified a function should retrieve users from all 3 let say. I'm not very advanced in programming in T-SQL yet so my question is -> can the variable be specified inside Openquery ? like for example SELECT * FROM Openquery(ADSI, 'SELECT EmployeeID, displayname, mailAddress, country FROM '' LDAP://MY-LDAP-PATH '' WHERE country=''@country' '   ') ACTIVE DIRECTORY HAS LIMITION OF RETRIEVING 1000 RECORDS AT ONCE - BUT NONE OF THESE COUNTRIES HAVE MORE THAN COUPLE HUNDREDS HOVWEVER summing them in one query this number of course will exceed 1000 recoreds so queries i think should be splitted and joined with union ??? Can anyone provide some example code of such function  The other problem i have is that openquery againt ADSI  above works correctly when i use SSMS localy on the server (connectin

Function retrieving users by country against (Active Directory) LDAP

  
Hello I've got such openquery SELECT * FROM Openquery(ADSI, 'SELECT EmployeeID, displayname, mailAddress, country FROM '' LDAP://MY-LDAP-PATH '' WHERE country=''coutry_code' '   ') country_code is 3 letters i think sth in format like USA, FRA etc I will need to retrieve users from up to 3 countries let say and i would like to create from this query above a stored procedure (or better a FUNCTION)  where someone calling a function can specify from which country does he/she wants to terieve users - when none country specified a function should retrieve users from all 3 let say. I'm not very advanced in programming in T-SQL yet so my question is -> can the variable be specified inside Openquery ? like for example SELECT * FROM Openquery(ADSI, 'SELECT EmployeeID, displayname, mailAddress, country FROM '' LDAP://MY-LDAP-PATH '' WHERE country=''@country' '   ') ACTIVE DIRECTORY HAS LIMITION OF RETRIEVING 1000 RECORDS AT ONCE - BUT NONE OF THESE COUNTRIES HAVE MORE THAN COUPLE HUNDREDS HOVWEVER summing them in one query this number of course will exceed 1000 recoreds so queries i think should be splitted and joined with union ??? Can anyone provide some example code of such function  The other problem i have is that openquery againt ADSI  above works correctly when i use SSMS localy on the server (connectin

people picker need to customize source of active directory users

  

Issue- setting the people picker to custom active directory OU

Scenario - The ad structure

Domain.com

     Company name(root)

      Department(OU)

                 General Users(OU)

                  Staff(OU)

Steps Taken

1)stsadm -o setsiteuseraccountdirectorypath -path "OU=STAFF,DC=domain,DC=com" -url http://domain.com

2)stsadm -o setproperty -url http://domain.com -pn peoplepicker-serviceaccountdirectorypaths -pv " OU=STAFF,DC=domain,DC=com "

 They  dont seem to have any effect on the people picker control as i can still get  all the users from all the different OUs.

I want to strict  it to the Staff OU.

IT seems really strange

In the Central admin > shared Services Providers> User Profile> Custom Source > I have set OU=STAFF,DC=domain, dc=com.

I found that the people picker is not connected to the user profiles.

:)

Any Idea Guys


Editing List that is populated by Active Directory

  

Hi,

I'm doing some work for a customer that has a Telephone Directory list on his Sharepoint intranet home page. The list is populated from the "Users & Groups" in sharepoint, but they can edit the entries to change things like extension numbers, etc within the list.

Recently, they have reported that they are unable to edit the entries. I have VPN'd onto their site and, indeed, they can't.

Having not designed their system myself, I can't confirm how the list was set up, so... here is my big ask:

1) How would this have most likley been set up?

2) What is the most likley cause for their newly-found restrictions?

They guy claims that he hasn't changed anything lately, but... well, we all know customers, right?

Sorry to be so vague about this. If I learn any more detail, I will post here.

Cheers,
AJ


Populate Drop-Down list box from Active Directory Data Connection?

  
Hi,

I recently created a data connection to my active directory, so that certain fields can be automatically populated given the user who is filling in the form.

However, I would like to have a drop-down box that is populated from Active Directory (i.e. the user of the form can select another AD member), the result of which will then populate other fields (with information such as Manager, Email Address, etc).

So, 2 questions:

  1. How do I get a drop-down list to populate with the members of AD?
  2. How do I get the result of this selection to populate other fields?
Cheers again - you guys are great!

Get list of users who have active or LIVE my sites

  
Is there a way we can get a list of users who have activated their My sites. OR at least a list of all the My Sites created by the users.

Problem With space When updating password of active directory users from asp.net

  

Hello Friend's


From long time i am facing problem with Reseting password of users of active directory from asp.net.


The coding is work fine when there are no space in username but it's cause a problem when there are space in username.


                      

usernametochange = "Ketan Patel";
                       ds.Filter = "(&(objectClass=user)(sAMAccountName=(" + usernametochange + ")))";
                       ds.PageSize = 100;

                       SearchResult account = ds.FindOne();
                       DirectoryEntry user = account.GetDirectoryEntry();
                       object[] oPassword = new object[] { "krtya#123" };

                       try
                       {
                           object ret = user.Invoke("SetPassword", oPassword);
                       }


if you have any idea about it please help me.


Thank you.....


Active Directory - List group managed by a specific user

  

Hello every body,

I need to know how I can find which groups of an active directory are managed by a specific user. The idea is to create a WinForm appication where the user enter a name and then, the code chek whicjh group of the AD is managed by the name entered.

Has someone any idea? I jusrt need specification about the Active Directory classes and methods...

Thanks ;-)


Active Directory Issue : Validation fails for newusers and few randon users

  

Hi All,

We started observing this behaviour from past couple of days. Even the AD Validation fails for the newly created users. So there are few users for whom the Active Directory authentication fails. We are not sure why it is happening. The code and configuration is not a problem since the same code works for other environment which has different domains. Has some one seen this kind of behaviour before. Infact we had a service to authenticate users so initial culprit was the service but now we have minimize the problem domain to AD. I created a simple application which JUST VALIDATES the user against the AD but still the same problem.  I am getting very generic error which does not seem to help in debugging.

Any help will be highly appreciated.

Event Type:   Information

Event Source: ASP.NET 2.0.50727.0

Event Category:       Web Event

Event ID:       1315

Date:            4/5/2011

Time:            3:35:42 PM

User:            N/A

Computer:     TRNMCS001

Description:

Event code: 4006

Event message: Membership credential verifi

Automatically validate names in SharePoint list to Active Directory names

  

I have some employee names in a list. Since there is employee turnover, I want to be able to keep a track of which employees have left so that I can take appropriate action. Currently it is a manual process to look at each member of the list and compare it against the GAL. Is there a OOTB feature / script / workflow I can use that does a check of the employee name against the name in Active Directory to ensure if the user still exists and if the user does not exist then it send an email to me automatically.


Ravi Acharya

Throws an error message while adding users to the Active Directory

  

Hello guys,

I am trying to add a user to active directory but for some reason its failing

 

Here is the error message


Message: HandlingInstanceID: dde791c2-7df4-4214-85c4-72b045510def

An exception of type 'System.Runtime.InteropServices.COMException' occurred and was caught.

-------------------------------------------------------------------------------------------

05/04/2011 15:18:30

Type : System.Runtime.InteropServices.COMException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Message : The server is not operational.

Source : System.DirectoryServices

Help link :

ErrorCode : -2147016646

Data : System.Collections.ListDictionaryInternal

TargetSite : Void Bind(Boolean)

Stack Trace : at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)

at System.DirectoryServices.DirectoryEntry.Bind()

at System.DirectoryServices.DirectoryEntry.get_IsContainer()

at System.DirectoryServices.DirectoryEntries.CheckIsContainer()

at System.DirectoryServices.DirectoryEntries.Add(String name, String schemaClassName)

.......................................

 


Unable to add users into sharepoint if i am Using emails as account name in Active Directory.

  
I am using moss 2007 version 12.0.0.6421. and Active directory version 6.0.. . my AD domain is siamint so if i add a user as vikas. it gets added in AD with logon name as vikas@siamint.com now if i add a user sahil@yahoo.com into ad. it gets added as sahil@yahoo.com@siamint. now when i try to add user from peoples and groups,site settings in a sharepoint site; i gets user siamint\sahil in people picker. rather it should be siamint\sahil@yahoo.com. it means the name is truncated from @. Is this a sharepoint error or what. Ultimately i think it means we cannot add users with @ in their usernames.

How to set SearchRoot Path in Active Directory in this scenario

  

How to set SearchRoot Path in Active Directory in this scenario:

Functionality: We have scenario that 1<sup>st</sup> hit one LDAP server with some 'fixed user name' &' fixed password ' and filter data with specific User name(which given by user) getting 'User dn'.

After that we hit Next LDAP server based on the 'User dn' getting from 1<sup>st</sup> server.

(So, in my case 1<sup>st</sup> LDAP server works like as Load balancing server but functionalitywise it is different)

|-------------------------------------------------------------------------------|
|                                         

active directory exception unusual behaviour

  

Hi 
i have a small problem
i want user names from active directory for an auto completer type of service
the method is always throwing an exception 
-------
"searcher.FindAll()' threw an exception of type 'System.DirectoryServices.DirectoryServicesCOMException' System.DirectoryServices.SearchResultCollection 

Active Directory and .NET: paging the search result

  
Hi everybody!

I have a question about Active Directory in .NET
For my project I need to fetch results from Active Directory search page by page, because later I would need to bind it to the pageable DataGrid.

I tried to use .NET library DirectoryServices for that, but paging provided by this library is transparent to the user and is used only to increase the efficiency of searching, when results are too big. I.e. I cannot tell the DirectorySearcher to give me first page, then the next or previous page, it returns me all resulting pages in one bundle.

However, what I need is to explicitely get page after page directly from the AD searcher and to be able to go at least one page forward or backward.

The solution with copying all results to the DataBase and then do the paging is not accepeted by the clent, since it is too inefficient. And since it's a Web app, I cannot keep results in memory either.

I found some hints about COM Interface, but I could not find good and detailed examples or explanations. I aslo found this line of code: DirectoryServices.Interop.IDirectorySearch.ExecuteSearch(), but I don't know which libraries should i add to be able to compile this code.

If somebody could help me out with that problem, any suggestion is welcome, 'cause this issue is eating me alive :)

Thank you!
Categories: 
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