.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

inequality search with System.DirectoryServices.AccountManagement.PrincipalSearcher?

Posted By:      Posted Date: September 24, 2010    Points: 0   Category :.NET Framework
 

The System.DirectoryServices.AccountManagement are a great time-saver when working with Active Directory!  But now I'm stuck.

Is it possible to use inequality searches with PrincipalSearcher?  For instance, i have users with three types:

Glubflabs
Abadabs
Foos

and possibly more.  I want only non-Foo users.  With PrincipalSearcher's underlying DirectorySearcher, i could give it a string filter like this:

filter.Append("(&(objectCategory=Person)(objectClass=user)(sAMAccountName=*)(!description=Foo))");

With PrincipalSearcher, that inequality doesn't seem to be possible!  I've searched all through MSDN articles and haven't found anything that covers this.

Any help is appreciated!




View Complete Post


More Related Resource Links

System.DirectoryServices.AccountManagement: FileNotFound exception while creating PrincipalContext o

  
Hi, I want to create a local group for my Netapp server. And also add a domain user under this group. Using .NET namepaces System.DirectoryServices.AccountManagement, I can achive this for Windows server. But if the same code is tried on NetApp, following exception is thrown: Unhandled Exception: System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)   at System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.GetInfo()   at System.DirectoryServices.DirectoryEntry.RefreshCache()   at System.DirectoryServices.AccountManagement.PrincipalContext.DoMachineInit()   at System.DirectoryServices.AccountManagement.PrincipalContext.Initialize()   at System.DirectoryServices.AccountManagement.PrincipalContext.get_QueryCtx()    at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(PrincipalContext context, Type principalType, Nullable`1 identityType, String identityValue, DateTime refDate)   at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithType(PrincipalContext context, Type principalType, String identityValue)   at System.DirectoryServices.AccountManagement.GroupPrincipal.FindByIdentity(PrincipalContext context, String identityValue)   at AddGroup.Program.Main(String[] args) Does S

System.DirectoryServices NOT available

  

I have simply copied a page from a VS2005 project to a VS2010 project, and it will not work.

NO code-behind, just a simple Page_Load function in the .aspx page.

and okay, since this editor complete f's up a cut and paste from VS, I will type it all out....wonderful!

 

<script runat="server">

protected void Page_Load(object sender, EvnetArgs e)

{

   System.DirectoryServices.DirectoryEntry ...

}

</script>

This is really all you need to see.

The System.DirectoryServices is not available in intellisense and gives an error if I try to run this.

I have added the reference to my VS project - no go.

I have added a reference as an @Import at the top of the page - no go.

All other System classes appear to be available, but not DirectoryServices, so anyone know the secret handshake to get this to work in VS 2010?


Code Name WinFS: Revolutionary File Storage System Lets Users Search and Manage Files Based on Conte

  

One of the monumental problems organizations face today is aggregating information that's stored in disparate formats. Knowledge workers have long wanted to be able to search for content independent of format. The next version of the Windows operating system, code-named "Longhorn," boasts a new storage subsystem that makes that task easier. That subsystem, code-named "WinFS," allows the user to perform searches based on the metadata of the stored item, regardless of what type of file it is or which application created it. This article covers the basic architecture of WinFS and explains how to use the WinFS managed API.

Richard Grimes

MSDN Magazine January 2004


Creating assembly throwing an error as system.directoryservices assembly is not in the SQL Server

  
Hi, I am trying to create an assembly (DLL file that created by C# ) which uses System.DirectoryServices assembly. When I try with following script Create ASSEMBLY Addresstype From 'C:\ActiDirectoryFunctions\ActiveDirectoryFunctions.dll' I am getting following Error Assembly 'ActiveDirectoryFunctions' references assembly 'system.directoryservices, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation has failed (reason: 2(The system cannot find the file specified.)). Please load the referenced assembly into the current database and retry your request. From above error message, I learnt that System.DirectoryServices assembly is not in the SQL Server. I am using SQL SERVER 2005 SP2 and .Net Framework 3 is there in the machine How to manually add this assembly into this SQL Server Machine? Please let me know if you know Thank you, Raj Dreaming a world without any war in anywhere

office search & Error 6482 during encryption or decryption. System error code 0

  

Occured when changed the password, all steps were successfull.

Same problem :http://social.technet.microsoft.com/Forums/en-US/sharepointsearch/thread/6194945b-1ec5-48b4-b827-d4ab998e046c

 Error Information:

04/05/2010 20:08:09.56 OWSTIMER.EXE (0x125C) 0x101C Office Server Office Server Shared Services 7u16 Critical Application Server Administration job failed for service instance Microsoft.Office.Server.Search.Administration.SearchAdminSharedWebServiceInstance (3a49bdd9-0f3e-4044-8def-78a59dd567c1). Reason: Error during encryption or decryption. System error code 0. Techinal Support Details: System.ArgumentException: Error during encryption or decryption. System error code 0. at Microsoft.SharePoint.Administration.SPCredentialManager.DecryptWithMasterKey(Byte[] rgbEncryptedPassphrase) at Microsoft.SharePoint.Administration.SPEncryptedString.GetSecureStringValue(Byte[] rgbEncryptedAlternateKey) at Microsoft.SharePoint.Administration.SPEncryptedString.GetSecureStringValue() at Microsoft.SharePoint.Administration.SPEncryptedString.get_SecureStringValue() at Microsoft.SharePoint.Adm... 04/05/2010 20:08:09.56* OWSTIMER.EXE (0x125C) 0x101C Office Server Office Server Shared Services 7u16 Critical ...inistration.SPProcessIdentity.get_

how to get system.directoryservices.dll to version no 2.0.50727.4927

  
Hi i have vista machine which has .net framework 2.0, 3.5, 3.5sp1, 4.0 installed and version no for system.directoryservices.dll is 2.0.50727.3053. i have another windows server r2 machine which has .net framework 2.0 and 3.5 installed on it and system.directoryservices.dll version is 2.0.50727.4927. could anyone tell me how to upgrade my vista dll to 2.0.50727.4927. i am surprised because i have all possible installation on vista but version is lower thn my r2 machine. i want this because we need to access addtional code defined in later version.

The search system not working

  

Hi,

My SharePoint Search system is not working, after doing some searches I have come to the following:

 

Form Search Administration I have found the following

-          Propagation status    (Query server not responding)

Performance Counters to monitor DirectoryServices.AccountManagement and Security.AccessControl activ

  

Hi Everyone,

I'm writing an application that takes in a file name as input, and then extracts its ACLs using FileSecurity.GetAccessRules().  Once I have these ACLs, I go through and identify each group member, obtain a group principal using Principal.FindByIdentity(), and traverse group principals using GroupPrincipal.GetMembers().  Undoubtedly the first call is going to hit the share where the file is located, and the next two calls are going to translate into LDAP queries against the AD server. 

I'm wondering, are there performance counters that I can attach to on the machine where the code runs so that I can monitor how hard I'm hitting each server?  The thing is that I'm not going to be able to attach a counter to the server iteself.  So Ideally, I would want to know how many bytes I'm sending out of this process per second.  I'm currently using category "Process", counter "IO Other Bytes/sec" to monitor activity.  However, this counter doesn't seem to map 1-to-1 from the data that it reports and the data that Perfmon reports on the network share / AD server.  The mapping seems to be more of a 1:5 relationship, so that when the local process reports that it's sending 10,000 bytes/sec, Perfmon reports that it's getting hit with 50,000 bytes/sec.  Is there a better counter to attach

Performance Counters to monitor DirectoryServices.AccountManagement and Security.AccessControl activ

  

Hi Everyone,

I'm writing an application that takes in a file name as input, and then extracts its ACLs using FileSecurity.GetAccessRules().  Once I have these ACLs, I go through and identify each group member, obtain a group principal using Principal.FindByIdentity(), and traverse group principals using GroupPrincipal.GetMembers().  Undoubtedly the first call is going to hit the share where the file is located, and the next two calls are going to translate into LDAP queries against the AD server. 

I'm wondering, are there performance counters that I can attach to on the machine where the code runs so that I can monitor how hard I'm hitting each server?  The thing is that I'm not going to be able to attach a counter to the server iteself.  So Ideally, I would want to know how many bytes I'm sending out of this process per second.  I'm currently using category "Process", counter "IO Other Bytes/sec" to monitor activity.  However, this counter doesn't seem to map 1-to-1 from the data that it reports and the data that Perfmon reports on the network share / AD server.  The mapping seems to be more of a 1:5 relationship, so that when the local process reports that it's sending 10,000 bytes/sec, Perfmon reports that it's getting hit with 50,000 byte

System.DirectoryService.AccountManagement Creating Local Profiles

  

Hello all!

I have a block of code that changes a users password as they enter it.  It appears that when they do this, it creates a local profile on the Windows 2008 Server for that user.  I'm doing it as follows...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.DirectoryServices.AccountManagement;
using System.Web.Hosting;
using System.Security;
using System.Security.Principal;
using System.DirectoryServices;

namespace ActiveDirectoryTools
{
    internal class ADProfileMgmt
    {
        PrincipalContext context;
        DirectoryEntry _entry = new DirectoryEntry();

        internal ADProfileMgmt(string domainName, string userName, string password)
        {
            context = new PrincipalContext(ContextType.Domain, domainName, userName, password);
        }

        internal UserPrincipal SearchUser(string userName)
        {
                UserPrincipal user = new UserPrincipal(context);
            
                user = UserPrincipal.FindByIdentity(context, userName);

                return user;    
        }

        internal void ChangePassword(string userName, string oldPassword, string newPassword)
        {
            UserPrincipal user = SearchUser(userName);

            user.ChangePassword(oldPassword, newPassword);
        }
    }
}

<

iis 7 IP Security using System.DirectoryServices : Unable to update

  

I used the below code to Set  IP Security from my vb.net Application.  It is working in IIS 6 (windows xp, and server 2003).

facing error in IIS 7.5 (windows7).

' Get the IIS object that holds the info for the default site.

 

Dim SecObj As Object = GetObject("IIS://LocalHost/W3SVC/1/Root/WebServerSCM")

 

' Get the IIsIPSecurity object.

System.Directoryservices vs activeds

  

I have a dumb question - If I have a reference to System.Directoryservices in my .NET application, should the system have activeds.tlb imported into registry ? Is there a relation between using System.DirectoryServices and activeds ?

 

Thanks.


System.BadImageFormatException: Could not load file or assembly 'Microsoft.Sharepoint.Search

  
I've done a fair amount of digging on this and have found this post that suggests that its caused by the .dll being marked for AMD and not for ia64.  This error occurred after I linked the new cluster to the existing sharepoint farm prior to migration.  Then started moving project files over and rebuilding for the upcoming new server name.  I've tried copying the .dll from the regular 12 hive into the GAC but it won't make a change to the processor architecture.

Do I need to re-run the configuration wizard or something?  Anyone have an easy fix?  Thanks.
Jack Burnish

What are the required Security permissions to call SAM accountmanagement over the wire, using System

  

Hi,

I need to perform remote management on the local SAM database.  I am getting a security permission error, but can't figure out what the required permissions need to be.  My test harness works great as a locally authenticated user however the permission issue gets thrown when I am trying to connect to a remote host that isn't part of the domain.

The exception is getting thrown on the call to ValidateCredentials, which is found in the constructor for the LocalAccount class below, specifically you will see it  public LocalAccount(string Server, string User, string Password)

My test environment includes windows 7 machines that are working in a offline mode trying to connect to machines running XP, 2003 and Windows 7 that are not part of the domain.

Any and all help would be appreciated.

Thanks
       

using System;
using System.Collections.Generic;
using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;


namespace WindowsManagement
{
  class Program
  {
    static 

Active Directory bulk data update error System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIf

  

Hello, 

we are trying to update bulk data into Active Directory from some database table. If we run for say 40000 users, it fails in between While updating its failing with an exception that. The server is not operational.

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.FindOne()

Below is the piece of code updating the records ...

================================================================================

While drDataReader.Read()
                strMailID = drDataReader.Item(("EMAILID")).ToString()
                strAttributeName = drDataReader.Item("ATTRIBUTENAME").ToString().Trim()
                strAttributeValue = drDataReader.Item("ATTRIBUTEVALUE").ToString().Trim()
         &

Creating a ContactPrincipal (DirectoryServices.AccountManagement)

  

Greetings,

I am attempting (failing miserably, and hopefully it's all my fault and someone will have good news) to create a class that represents an Active Directory Contact object.  This is added to the Active Directory schema after you install Exchange.

I started by inheriting from System.DirectoryServices.AccountManagement.Principal, just like all the other Principals do (at least at their core, though User/Computer principals use an intermediary class called AuthenticablePrinciple).  But it seems like Microsoft does not want you actually making your own Principals for AD... This becomes obvious very quickly when you try to actually do anything with this inheritance... For instance, there is no way to store the PrincipalContext object inside the newly created ContactPrincipal since MyBase.Context is readonly, ContextRaw is a protected friend, and the actual storage value, ctx, is private...  So even when I use reflector to see how they store the context, in say GroupPrincipal, I find I can't duplicate this process as all the variables are inaccessible...

The next thing I tried was inheriting from UserPrincipal, even though in Active Directory the Contact object type is not a user, though it does share many other types with user.  I applied the DirectoryObjectClass attribute (with a value of "contact"),

System.DirectoryServices.DirectoryServicesCOMException: A referral was returned from the server.

  

I am trying to display all the properties for a user on a webpage.  This code works fine on the local workstation but when I try to run it on the iss server I get the following error:

Exception Details: System.DirectoryServices.DirectoryServicesCOMException: A referral was returned from the server.
If I comment out the Dim sr as searchresult... I do not get the error.  Here is the code:

Using
domain__1 As

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