Share via


Copying Rights from URLs

Copying Rights from URLs

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release. Copyrightsfromurl1tourl2.asp extracts the rights that a user has on a certain URL and adds the same rights for that user to another URL.

<%
//  This sample creates a user named "User2" on ITEM2 that has same rights as "User2" on ITEM2.
function CopyRightsFromURL1ToURL2(NT4user, itemURL1, itemURL2)
{
    var objDacl1 = CreateSecurityDACL(SECURITY_ON_SERVER());
    var objDacl2 = CreateSecurityDACL(SECURITY_ON_SERVER());

    // Load the 2 dacl from the 2 items.
    var objLoadDacl1Result = objDacl1.Load(itemURL1);
    if (objLoadDacl1Result.number != 0)
    {
          Response.Write("<b>Failed to Load: " + objLoadDacl1Result.description + "</b><br>");
        //error loading the object ...maybe the url does not exist....
        Return(objLoadDacl1Result.number);
    }

    var objLoadDacl2Result = objDacl2.Load(itemURL2);
    if (objLoadDacl2Result.number != 0)
    {
          Response.Write("<b>Failed to Load: " + objLoadDacl2Result.description + "</b><br>");
        //error loading the object ...maybe the url does not exist....
        return(objLoadDacl2Result.number);
    }

    //get the 2 users
    var entityUser1 = objDacl1.SearchForObjectByNT4Name(NT4user);
    if (null == entityUser1)
    {
          Response.Write("<b>Failed to Search for object by display name</b><br>");
        return(-1);   //maybe the user does not exist......
    }

    var objResult = objDacl2.AddSimpleSecurityEntity(NT4user,entityUser1.Masks);
    //we use the function here because the user may be in the dacl already
    //add returns a 1 if the user is in the dacl already
    if(FAILED(objResult.number))
    {
       Response.Write("<b>Failed to AddSimpleSecurityEntity</b><br>");
      return(objResult.number);
    }

    objResult = objDacl2.Save();
    if (objResult.number != 0)
    {
        Response.Write("<b>Failed to Save DACL: " + objResult.description + "</b><br>");
       return(objResult.number);
    }

 return(0); //no errors
}
%>



Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.