|
Home > Archive > Microsoft Content Management Server > November 2004 > CMS and AD
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Also, The main part of my code is coming off stefans site
code below: The error is that the object reference is not
being set to an instance of an object. Then it points at
the line of code with this:
string MailAddr = result.Properties["mail"][0].ToString
(); - as the source of the dead object reference.
if (dirEntry != null)
{
DirectorySearcher
dirSearcher = new DirectorySearcher();
dirSearcher.SearchRoot =
dirEntry;
dirSearcher.Filter =
UserFilter;
dirSearcher.SearchScope =
SearchScope.Subtree;
dirSearcher.PropertiesToLoad.Add("mail");
SearchResult result =
dirSearcher.FindOne();
string MailAddr =
result.Properties["mail"][0].ToString();
//string MailAddr =
result.Properties.PropertyNames.ToString();
dirSearcher.Dispose
();
dirEntry.Dispose
();
return(MailAddr);
}
Help!!
Joey
| |
| Dominik 2004-11-03, 2:47 am |
| Hi Joey,
has the CMS rights to access the AD? If you do not do any impersonating then
i think the CMS is accessing the AD under the Network Service Account. I had
the same problem here and we now let the Application run impersonated under a
domain service account that has access to the AD.
Cheers,
Dominik
"Joey" wrote:
> Also, The main part of my code is coming off stefans site
> code below: The error is that the object reference is not
> being set to an instance of an object. Then it points at
> the line of code with this:
>
> string MailAddr = result.Properties["mail"][0].ToString
> (); - as the source of the dead object reference.
>
>
>
> if (dirEntry != null)
> {
> DirectorySearcher
> dirSearcher = new DirectorySearcher();
> dirSearcher.SearchRoot =
> dirEntry;
> dirSearcher.Filter =
> UserFilter;
> dirSearcher.SearchScope =
> SearchScope.Subtree;
>
> dirSearcher.PropertiesToLoad.Add("mail");
> SearchResult result =
> dirSearcher.FindOne();
> string MailAddr =
> result.Properties["mail"][0].ToString();
> //string MailAddr =
> result.Properties.PropertyNames.ToString();
> dirSearcher.Dispose
> ();
> dirEntry.Dispose
> ();
> return(MailAddr);
> }
>
> Help!!
>
>
> Joey
>
>
| |
| Stefan [MSFT] 2004-11-03, 2:47 am |
| Hi Joey,
the error indicates one of the objects contains null.
Please instrument your code or better attach the debugger and check which
object is not correctly set.
Then identify the line where this object needs to be set and check what's
going wrong.
Cheers,
Stefan.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
MCMS FAQ:
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...t+S
erver
MCMS Whitepapers and other docs:
http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
--------------------------------
"Joey" <anonymous@discussions.microsoft.com> wrote in message
news:38eb01c4c13c$3ab3b1b0$a301280a@phx.gbl...
> Also, The main part of my code is coming off stefans site
> code below: The error is that the object reference is not
> being set to an instance of an object. Then it points at
> the line of code with this:
>
> string MailAddr = result.Properties["mail"][0].ToString
> (); - as the source of the dead object reference.
>
>
>
> if (dirEntry != null)
> {
> DirectorySearcher
> dirSearcher = new DirectorySearcher();
> dirSearcher.SearchRoot =
> dirEntry;
> dirSearcher.Filter =
> UserFilter;
> dirSearcher.SearchScope =
> SearchScope.Subtree;
>
> dirSearcher.PropertiesToLoad.Add("mail");
> SearchResult result =
> dirSearcher.FindOne();
> string MailAddr =
> result.Properties["mail"][0].ToString();
> //string MailAddr =
> result.Properties.PropertyNames.ToString();
> dirSearcher.Dispose
> ();
> dirEntry.Dispose
> ();
> return(MailAddr);
> }
>
> Help!!
>
>
> Joey
>
|
|
|
|
|