public static string GetOrSetUserProfileDir(string username, string domain, string password)
{
string ret = "";
StringBuilder path = new StringBuilder(260);
uint path_size = Convert.ToUInt32(path.Capacity);
IntPtr hToken = GetUserToken(username, domain, password);
if (hToken == IntPtr.Zero)
{
LibraryLogging.Error("GetOrSetUserProfileDir can't get userToken");
return "";
}
ret = GetUserProfileDir(hToken);
if (String.IsNullOrEmpty(ret))
{
ret = CreateUserProfileDir(hToken, username);
if (String.IsNullOrEmpty(ret))
{
LibraryLogging.Error("GetOrSetUserProfileDir failed to get and create profile error:{0}", LastError());
}
}
SafeNativeMethods.CloseHandle(hToken);
return ret;
}