J
Jondis
I've been working on a Web Part that can update Active
Directory for some time.
I'm trying to give SharePoint administrators the ability
to add users (which requires the user to be in Active
Directory before he is added to SharePoint). I also want
to give regular users the ability to update their Active
Directory password from within SharePoint.
So far, I've successfully encapsulated my Active
Directory code into a DLL and installed it into the GAC
with the AllowPartiallyTrustedCallersAttribute.
Calling into my Active Directory object from a regular
ASP.NET web application (.ASPX page) works PERFECTLY:
Adds, Updates, Deletes.
However, when I try to call the Active Directory object
from SharePoint I get security errors:
When I simply try to load an Active Directory
DirectoryServicesEntry:
System.UnauthorizedAccessException
General access denied error
StackTrace " at
System.DirectoryServices.Interop.IAdsContainer.GetObject
(String className, String relativeName)
at System.DirectoryServices.DirectoryEntries.Find
(String name, String schemaClassName)
at DirectoryServicesHelper.UserAdmin.LoadUser(String
username)
at Evolve.SharePoint.PortalUser.GetADUser() in \\TC2
\Users\Jonathan Discount\My Documents\Visual Studio
Projects\Evolve.SharePoint.UserAdministration\Evolve.Share
Point.PortalUser.vb:line 55 at
Evolve.SharePoint.UserAdministration.btnSaveChanges_Click
(Object sender, EventArgs e) in \\TC2\Users\Jonathan
Discount\My Documents\Visual Studio
Projects\Evolve.SharePoint.UserAdministration\Evolve.Share
Point.UserAdministration.vb:line 678" String
When I get a little more ambitious and try to save to
Active Directory:
System.Runtime.InteropServices.COMException
Unspecified Error
StackTrace " at
System.DirectoryServices.Interop.IAdsContainer.Create
(String className, String relativeName)
at System.DirectoryServices.DirectoryEntries.Add
(String name, String schemaClassName)
at DirectoryServicesHelper.UserAdmin.SaveUser(DSUser
dsUser)
at Evolve.SharePoint.PortalUser.Save(String fullName)
in \\TC2\Users\Jonathan Discount\My Documents\Visual
Studio
Projects\Evolve.SharePoint.UserAdministration\Evolve.Share
Point.PortalUser.vb:line 63" String
I've made a number of modifications to SharePoint's
security settings via a Custom Policy File, including
adding:
<SecurityClass Name="DirectoryServicesPermission"
Description="System.DirectoryServices.DirectoryServicesPer
mission, System.DirectoryServices, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
Next, I created a NamedPermissionSet for my Web Part:
<PermissionSet class="NamedPermissionSet" version="1" Name="856644171da596d2">
<IPermission class="AspNetHostingPermission" version="1" Level="Medium" />
<IPermission class="SecurityPermission" version="1" Flags="AllFlags" />
<IPermission class="WebPartPermission" version="1" Connections="True" />
<IPermission class="DirectoryServicesPermission" version="1"
Unrestricted="True" />
<IPermission class="SharePointPermission" version="1" ObjectModel="True" />
<IPermission class="SqlClientPermission" version="1" Unrestricted="True" />
</PermissionSet>
Finally, I added a UnionCodeGroup (it's the first one):
<CodeGroup class="UnionCodeGroup" version="1"
PermissionSetName="856644171da596d2">
<IMembershipCondition version="1" AssemblyVersion="1.0.0.0"
Name="Evolve.SharePoint.UserAdministration"
class="StrongNameMembershipCondition"
PublicKeyBlob="0x002400000480000094000000060200000024000052534131000400000100010087992946CC13DCBBF3984C463A24970597
1BF1FED8F874CAC4C1EAA5BBFCFF7B8922D30BBE26BE7BA0838D5283D8B81A06399A176A473C292704EE4C5C0C2F0C2F39E903F1627233D53F2CFE28D6943
AE5FED8B75DC53AD41B5484C06750F955B7392D7700DF222A60CFE8D297ABEE9C5F5D53839D40A08FF3FBAE0BF09CED5" />
</CodeGroup>
I experimented with impersonation in the web.config file
but it caused problems elsewhere: SharePoint's default is
<identity impersonate="true" />. I added an
administrator account to the identity declaration and I
got a little farther: I could query AD, but not update
it. However, the impersonation screwed up "My Site".
Everytime I went to "My Site" it would load the
administrator's personal site (regardless of which
account I'd used to log in). So impersonation is back to
the default:
<identity impersonate="true" />
(no account specified).
What other modifications do I need to make to the
SharePoint security config to authorize my Web Part for
Active Directory?
PLEASE HELP!!!
Thanks,
JD
Directory for some time.
I'm trying to give SharePoint administrators the ability
to add users (which requires the user to be in Active
Directory before he is added to SharePoint). I also want
to give regular users the ability to update their Active
Directory password from within SharePoint.
So far, I've successfully encapsulated my Active
Directory code into a DLL and installed it into the GAC
with the AllowPartiallyTrustedCallersAttribute.
Calling into my Active Directory object from a regular
ASP.NET web application (.ASPX page) works PERFECTLY:
Adds, Updates, Deletes.
However, when I try to call the Active Directory object
from SharePoint I get security errors:
When I simply try to load an Active Directory
DirectoryServicesEntry:
System.UnauthorizedAccessException
General access denied error
StackTrace " at
System.DirectoryServices.Interop.IAdsContainer.GetObject
(String className, String relativeName)
at System.DirectoryServices.DirectoryEntries.Find
(String name, String schemaClassName)
at DirectoryServicesHelper.UserAdmin.LoadUser(String
username)
at Evolve.SharePoint.PortalUser.GetADUser() in \\TC2
\Users\Jonathan Discount\My Documents\Visual Studio
Projects\Evolve.SharePoint.UserAdministration\Evolve.Share
Point.PortalUser.vb:line 55 at
Evolve.SharePoint.UserAdministration.btnSaveChanges_Click
(Object sender, EventArgs e) in \\TC2\Users\Jonathan
Discount\My Documents\Visual Studio
Projects\Evolve.SharePoint.UserAdministration\Evolve.Share
Point.UserAdministration.vb:line 678" String
When I get a little more ambitious and try to save to
Active Directory:
System.Runtime.InteropServices.COMException
Unspecified Error
StackTrace " at
System.DirectoryServices.Interop.IAdsContainer.Create
(String className, String relativeName)
at System.DirectoryServices.DirectoryEntries.Add
(String name, String schemaClassName)
at DirectoryServicesHelper.UserAdmin.SaveUser(DSUser
dsUser)
at Evolve.SharePoint.PortalUser.Save(String fullName)
in \\TC2\Users\Jonathan Discount\My Documents\Visual
Studio
Projects\Evolve.SharePoint.UserAdministration\Evolve.Share
Point.PortalUser.vb:line 63" String
I've made a number of modifications to SharePoint's
security settings via a Custom Policy File, including
adding:
<SecurityClass Name="DirectoryServicesPermission"
Description="System.DirectoryServices.DirectoryServicesPer
mission, System.DirectoryServices, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
Next, I created a NamedPermissionSet for my Web Part:
<PermissionSet class="NamedPermissionSet" version="1" Name="856644171da596d2">
<IPermission class="AspNetHostingPermission" version="1" Level="Medium" />
<IPermission class="SecurityPermission" version="1" Flags="AllFlags" />
<IPermission class="WebPartPermission" version="1" Connections="True" />
<IPermission class="DirectoryServicesPermission" version="1"
Unrestricted="True" />
<IPermission class="SharePointPermission" version="1" ObjectModel="True" />
<IPermission class="SqlClientPermission" version="1" Unrestricted="True" />
</PermissionSet>
Finally, I added a UnionCodeGroup (it's the first one):
<CodeGroup class="UnionCodeGroup" version="1"
PermissionSetName="856644171da596d2">
<IMembershipCondition version="1" AssemblyVersion="1.0.0.0"
Name="Evolve.SharePoint.UserAdministration"
class="StrongNameMembershipCondition"
PublicKeyBlob="0x002400000480000094000000060200000024000052534131000400000100010087992946CC13DCBBF3984C463A24970597
1BF1FED8F874CAC4C1EAA5BBFCFF7B8922D30BBE26BE7BA0838D5283D8B81A06399A176A473C292704EE4C5C0C2F0C2F39E903F1627233D53F2CFE28D6943
AE5FED8B75DC53AD41B5484C06750F955B7392D7700DF222A60CFE8D297ABEE9C5F5D53839D40A08FF3FBAE0BF09CED5" />
</CodeGroup>
I experimented with impersonation in the web.config file
but it caused problems elsewhere: SharePoint's default is
<identity impersonate="true" />. I added an
administrator account to the identity declaration and I
got a little farther: I could query AD, but not update
it. However, the impersonation screwed up "My Site".
Everytime I went to "My Site" it would load the
administrator's personal site (regardless of which
account I'd used to log in). So impersonation is back to
the default:
<identity impersonate="true" />
(no account specified).
What other modifications do I need to make to the
SharePoint security config to authorize my Web Part for
Active Directory?
PLEASE HELP!!!
Thanks,
JD