0

안녕하세요, C#을 사용하여 Windows 저장소 응용 프로그램에 새 Windows 8/8.1 사용자를 만들려고합니다. "System.DirectoryServices.AccountManagement"네임 스페이스를 사용할 수 없기 때문에 아래 코드를 사용할 수 없습니다.Windows 저장소 앱으로 새 Windows 8/8.1 사용자 만들기

public UserPrincipal CreateNewUser(string a_userName, string sPassword) 
{ 
    if (!UserExists(a_userName)) 
    { 
     PrincipalContext oPrincipalContext = GetPrincipalContext(); 

     UserPrincipal oUserPrincipal = new UserPrincipal(oPrincipalContext); 
     oUserPrincipal.Name = a_userName; 
     oUserPrincipal.SetPassword(sPassword); 
     //User Log on Name 
     oUserPrincipal.UserPrincipalName = a_userName; 
     oUserPrincipal.Save(); 

     return oUserPrincipal; 
    } 

    // if it already exists, return null   
    return null; 
} 

private PrincipalContext GetPrincipalContext() 
{ 
    PrincipalContext oPrincipalContext = new PrincipalContext(ContextType.Machine); 
    return oPrincipalContext; 
} 

private bool UserExists(string a_userName) 
{ 
    using (var pc = new PrincipalContext(ContextType.Machine)) 
    { 
     using (var p = Principal.FindByIdentity(pc, IdentityType.SamAccountName, a_userName)) 
     { 
      return p != null; 
     } 
    } 
} 

우리는 모든 네임 스페이스의 필수품이 윈도우 스토어 응용 프로그램 프로젝트에 사용할 수 없기 때문에 윈도우 사용자를 생성 (이 나던 문제로 또는 암호없이) 할 수있는 방법을 찾을 방법을 알고하지는.

우리는 오류가 일부 DLL을 가져올 경우

"참조로"[DLL이 경로] "파일 대상 '.NetFramework'동안 프로젝트 대상 '닷넷 코어'추가 할 수 없습니다. 이것은 지원되는 장면이 아닙니다. "

가능한 해결책이 있습니까?

답변

2

이것은 가능하지 않으며 그러지 않아야합니다. Windows 스토어 앱은 거대한 엄청난 보안 위험이 있기 때문에 사용자 생성 권한이 없습니다! 너 왜 이러는거야?

+0

수정. AccountManagement는 앱을 저장하는 데 사용할 수없는 "완전 신뢰"API입니다. OS 자체, Store/PC 설정, 데스크톱 응용 프로그램과 같은받은 편지함 (권한있는) 응용 프로그램을위한 여러 가지 API가 있습니다. –

관련 문제