"David Jenkins Toppan" <Da****************@discussions.microsoft.comwro te
in message news:1B**********************************@microsof t.com...
I'm really having a hard time using DirectoryServices.AccountManagement.
I
seem to be able to get it to work fine in Visual Web Developer 2008 but
when
I deploy to a IIS Server I get cast issues.
I have a screenshot here:
http://forums.asp.net/p/1210311/2131427.aspx#2131427
Unable to cast object of type
'System.DirectoryServices.AccountManagement.GroupP rincipal' to type
'System.DirectoryServices.AccountManagement.UserPr incipal'.
You are running in the context of a group SID, not a user account SID.
If ASP.NET is running as NT_AUTHORITY\NETWORK SERVICE or NT_AUTHORITY\LOCAL
SERVICE, then the current user SID is a group SID and the cast to a
UserPrincipal will fail (this is normal). So, you need to make sure that you
run in the context of a user account, or you need to catch this exception
and take the appropriate action.
Willy.