Re: error: {System.Runtime.InteropServices.COMException} occured
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Wed, 3 Aug 2005 22:34:11 +0200
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
>
.
- Follow-Ups:
- References:
- Prev by Date: Re: OO style Webservices or not
- Next by Date: Tabcontrol with image
- Previous by thread: Re: error: {System.Runtime.InteropServices.COMException} occured
- Next by thread: Re: error: {System.Runtime.InteropServices.COMException} occured
- Index(es):
Relevant Pages
|