Microsoft Information Protection SDK는 두 가지 기본 유형의 레이블 기반 권한인 템플릿 기반 및 사용자 정의 권한을 지원합니다.
템플릿 기반 권한: 이러한 권한은 보안 및 규정 준수 센터의 레이블 관리자에 의해 정의됩니다. 이러한 레이블은 중앙에서 관리되며 구성의 변경 내용은 이미 파일 복사본이 있는 사용자에게 영향을 줍니다. 예를 들어 관리자가 권한 있는 사용자 목록에서 사용자를 제거하는 경우 다음에 라이선스를 가져오려고 할 때 해당 사용자는 더 이상 보호된 데이터에 액세스할 수 없습니다.
사용자 정의 권한: 이러한 권한은 최종 사용자 또는 애플리케이션에서 레이블을 지정할 때 정의됩니다. 권한은 사용자-역할 또는 사용자-권한 매핑 컬렉션의 형태로 MIP SDK에 전달됩니다. 이러한 권한은 보호된 문서에 대한 게시 라이선스에 기록되며 템플릿 기반 사용 권한과 달리 직접 액세스하고 문서를 수정하지 않고 공유한 후에는 중앙에서 관리하거나 수정할 수 없습니다.
사용자, 권한 및 역할
레이블 지정 시 사용자가 권한을 정의할 것으로 예상되므로 애플리케이션은 사용자 또는 서비스가 사용자가 가질 이메일 주소 및 권한 또는 역할에 대한 입력을 제공할 수 있도록 인터페이스를 제공해야 합니다. 이 구성은 문서에 대한 액세스 수준을 가져야 하는 사용자를 구체적으로 정의하는 개체 또는 UserRolesUserRights 컬렉션을 전달하여 수행됩니다.
// Create a List<string> of the first set of permissions.
List<string> users = new List<string>()
{
"alice@contoso.com",
"bob@contoso.com"
};
// Create a List<string> of the Rights the above users should have.
List<string> rights = new List<string>()
{
Rights.View,
Rights.Edit
};
// Create a UserRights object containing the defined users and rights.
UserRights userRights = new UserRights(users, rights);
// Add them to a new List<UserRights>
List<UserRights> userRightsList = new List<UserRights>()
{
userRights
};
그 결과, Alice와 Bob이 보호된 파일에 대해 VIEW와 EDIT 권한을 갖고 있음을 지정하는 List<UserRights> 컬렉션이 생성됩니다.
다른 사용 권한 집합을 가진 사용자를 더 추가하려면 프로세스를 반복하여 두 번째 UserRights 개체를 만들고 새 사용자 및 권한을 전달한 다음 호출userRightsList.Add(userRights2)하여 List<UserRights> 컬렉션에 추가합니다.
이 패턴은 또한 UserRoles에 대해 적용될 수 있으며, 권한을 역할로 대체하고 List<UserRoles> 컬렉션을 만들어 간단히 구현할 수 있습니다.
도메인 보호
도메인에 대해 사용자 정의 권한을 적용하려면 잘 알려진 메일 접두사 및 대상 도메인을 메일 주소로 사용해야 합니다. 해당 주소는 다음과 AllStaff-7184AB3F-CCD1-46F3-8233-3E09E9CF0E66@contoso.com같습니다.
애플리케이션에서 사용자는 contoso.com 또는 fabrikam.com 같은 도메인을 지정할 수 있어야 합니다. 애플리케이션에서 보호 설명자를 만들 때 AllStaff-7184AB3F-CCD1-46F3-8233-3E09E9CF0E66@ 도메인 접미사 앞에 추가해야 합니다.
아래 샘플에서는 사용자가 alice@contoso.com 및 전체 Fabrikam.com을 유효한 수신자로 지정했다고 가정합니다.
// Create a List<string> of the first set of permissions.
List<string> users = new List<string>()
{
"alice@contoso.com",
"AllStaff-7184AB3F-CCD1-46F3-8233-3E09E9CF0E66@fabrikam.com"
};
// Create a List<string> of the Rights the above users should have.
List<string> rights = new List<string>()
{
Rights.View,
Rights.Edit
};
// Create a UserRights object containing the defined users and rights.
UserRights userRights = new UserRights(users, rights);
// Add them to a new List<UserRights>
List<UserRights> userRightsList = new List<UserRights>()
{
userRights
};
보호 적용
설정 보호는 List<UserRights> 또는 List<UserRoles> 개체에서 ProtectionDescriptor를 생성하고, 이를 FileHandler.SetProtection()에 전달하여 수행할 수 있습니다. 마지막으로 파일 변경 내용을 커밋하여 새 파일을 작성합니다.
파일에 보호를 적용하는 경우
MIP SDK를 통해 FileHandler.SetLabel() 레이블을 설정하는 경우 조치를 취하고 보호를 적용하는 데 필요한 모든 것이 있습니다. 레이블이 UDP(사용자 정의 권한)에 대해 구성된 경우 애플리케이션은 레이블이 UDP 레이블임을 미리 알 수 없습니다. MIP SDK는 형식 Microsoft.InformationProtection.Exceptions.AdhocProtectionRequiredException의 예외를 throw하여 이 정보를 표시합니다.
FileHandler 코드는 이 예외를 catch한 다음 사용자 또는 서비스 인터페이스를 트리거하여 사용자 지정 권한을 정의해야 합니다. 완료되면 보호를 설정할 수 있습니다. 다음 예제에서는 엔드 투 엔드 패턴을 보여 주지만 개체를 빌드 List<UserRights> 하는 함수를 이미 구현했다고 가정합니다.
try
{
// Attempt to set the label. If it's a UDP label, this will throw.
handler.SetLabel(engine.GetLabelById(options.LabelId), labelingOptions, new ProtectionSettings());
}
catch (Microsoft.InformationProtection.Exceptions.AdhocProtectionRequiredException)
{
// Assumes you've create a function that returns the List<UserRights> as previously detailed.
List<UserRights> userRightsList = GetUserRights();
// Create a ProtectionDescriptor using the set of UserRights.
ProtectionDescriptor protectionDescriptor = new ProtectionDescriptor(userRightsList);
// Apply protection to the file using the new ProtectionDescriptor.
handler.SetProtection(protectionDescriptor, new ProtectionSettings());
// Set the label. This will now succeed as protection has been defined.
handler.SetLabel(engine.GetLabelById(options.LabelId), labelingOptions, new ProtectionSettings());
// Commit the change.
var result = Task.Run(async () => await handler.CommitAsync("myFileOutput.xlsx")).Result;
}
사용자 지정 보호
이 프로세스는 보호를 설정한 후 SetLabel() 단계를 건너뛰어 보호만 설정하는데 사용할 수 있습니다. 애플리케이션에서 레이블을 적용할 필요가 없는 경우 예외 처리기가 필요하지 않으며 -CommitAsync()>SetProtection()> 패턴을 따라 ProtectionDescriptor 보호를 설정할 수 있습니다.