Re: error: {System.Runtime.InteropServices.COMException} occured



Run your code first from a console application before you run this from
asp.net. What you need is a HRESULT code or a complete stack trace, the
"System.Runtime.InteropServices.COMException" is of little help really.

Willy.

"iusfani" <Inam.Yousfani@xxxxxxxxx> wrote in message
news:1123095786.834134.312390@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi,
>
> I am trying to connect with Active Directory & Active Directory
> Application Mode(AD/AM), and want to pull down user's information, but
> unfortunately I am encountering an error, which is like:
>
> <error: an exception of type:
> {{System.Runtime.InteropServices.COMException} occured>
>
> Actually what I am trying to do is, I have designed a very simple
> ASP.NET page, I am passing userID from there and want to get the user's
> profile from AD and/or AD/AM. The code for getting user's information
> is:
>
> ========================Code Snippet============================
> private void getUserData(string UserID)
> {
> DirectoryEntry de = new DirectoryEntry();
> DirectorySearcher aSearcher = new DirectorySearcher(de);
> StringBuilder filter = new StringBuilder();
> filter.AppendFormat("(anr = {0})", UserID);
> aSearcher.Filter = filter.ToString();
> SearchResult searchResult = aSearcher.FindOne();
>
> if(searchResult != null){
> DirectoryEntry directoryObject = searchResult.GetDirectoryEntry();
> if(directoryObject.Properties["name"].Value != null)
> name = (string)directoryObject.Properties["name"].Value;
>
> if(directoryObject.Properties["regionID"].Value != null)
> this.regionID =
> Int32.Parse(directoryObject.Properties["regionID"].Value.ToString());
> else
> this.regionID = 20;
> if (directoryObject.Properties["districtID"].Value!=null)
> this.districtID =
> Int32.Parse(directoryObject.Properties["districtID"].Value.ToString());
> else
> this.districtID=20;
> if (directoryObject.Properties["homePhone"].Value !=null)
> this.claimsOfficerID =
> Int32.Parse(directoryObject.Properties["claimsOfficerID"].Value.ToString());
> else
> this.claimsOfficerID=-1;
> }
> else
> {
> throw new NullReferenceException("No such directory entry exists");
> }
> ==========================End Code===============================
>
> Now, When I call getUserData(...) method it throws an error "<error:
> {System.Runtime.InteropServices.COMException} occured>"
>
> Could any one please let me know why is that so?
>
> Would be highly appreciated.
>
> Thanks,
>
> Inam
>


.



Relevant Pages

  • Re: System.DirectoryServices questions
    ... The problem is how am I supposed to test whether a connection is active or not if I can create a DirectoryEntry with whatever data I want since the data really isn't verified until I try to use it? ... A connection is only established when you execute a method on that class, that binds to the directory service as part of it's implementation. ... And since my test environment is my PC connecting to an installation of Active Directory running within a virtual machine on my PC and my PC isn't a member of the domain I'm connecting to the Existsmethod will fail for me. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Passing security context to COM object
    ... If a Web application needs to access Active Directory, ... explicit credentials to the DirectoryEntry constructor in the ... Try supplying explicit credentials like this: DirectoryEntry entry = new ... | the security context of the logged-in user to ensure the user has the ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: System.DirectoryServices - The server is not operational
    ... I can successfuly bind to Active Directory using the ldp.exe tool. ... >Authentication to authenticate against our Active Directory. ... > I'm getting an Exception when I try to create a new DirectoryEntry to try ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: System.DirectoryServices questions
    ... The problem is how am I supposed to test whether a connection is active or not if I can create a DirectoryEntry with whatever data I want since the data really isn't verified until I try to use it? ... A connection is only established when you execute a method on that class, that binds to the directory service as part of it's implementation. ... And since my test environment is my PC connecting to an installation of Active Directory running within a virtual machine on my PC and my PC isn't a member of the domain I'm connecting to the Existsmethod will fail for me. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: LDAP vs. Active Directory Attributes
    ... System.DirectoryServices namespace has to be one of the most ridiculously ... When referring to the 'Properties' collection of a DirectoryEntry object, ... the Platform SDK from Microsoft references all the Active Directory ... then that would be the Path property of the DirectoryEntry class. ...
    (microsoft.public.dotnet.languages.vb)